Providers
Providers are the blockchain connectors. A provider is instantiated internally based on the network name provided on initialization.
Available Providers
const eoslime = require('eoslime').init('jungle') -> JungleProvider
Properties
network
{
name: 'network name',
url: 'node endpoint',
chainId: 'chain id'
}
defaultAccount
The default/main account from which the blockchain transactions are executed
eos
eosjs instance that serves as a bridge with the blockchain
Functions
reset
Reset the provider to another one
If you reset the provider, the whole eoslime and all of it's objects will change entirely the old provider with the new one
const eoslimeInstance = eoslime.init();
const localProvider = eoslimeInstance.Provider;
assert(JSON.stringify(localProvider.network) == JSON.stringify(Networks.local));
const localAccount = await eoslimeInstance.Account.createRandom();
assert(JSON.stringify(localAccount.provider.network) == JSON.stringify(Networks.local));
const jungleProvider = new eoslimeInstance.Provider('jungle');
eoslimeInstance.Provider.reset(jungleProvider);
assert(JSON.stringify(localAccount.provider.network) == JSON.stringify(Networks.jungle));
assert(JSON.stringify(eoslimeInstance.Provider.network) == JSON.stringify(Networks.jungle));
getABI(contractName)
Returns contract ABI in JSON format
const abiJSON = await Provider.getABI('contract name');
getRawWASM(contractName)
Returns raw WASM useful for deploying another contract directly
const rawWASM = await Provider.getRawWASM('contract name');
Query Chain Style
In order to be easier for developers to read from a table we have implemented query chain like table search.
Provider.select('table').from('contract name')
.equal()
.range()
.limit()
.index()
.find();
Every query should ends with find() in order to be executed.
select(tableName)
Required parameters
tabletName
Provider.select('table')
Possible next subqueries
from
from(contractName)
Required parameters
contractName
Provider.select('table').from('contract name')
Possible next subqueries
scope
find
equal
range
limit
index
scope(accountName)
Required parameters
accountName
If you skip scope, the default one will be set to the from
Provider.select('table').from('contract name').scope('account name')
Possible next subqueries
find
equal
range
limit
index
equal(value)
Required parameters
value
Provider.select('table').from('contract name').equal(5)
Possible next subqueries
find
limit
index
range(from, to)
Required parameters
from
to
Provider.select('table').from('contract name').range(1, 5)
Possible next subqueries
find
limit
index
index(index, indexType)
Required parameters
index
Optional parameters
indexType = i64
Provider.select('table').from('contract name').index(1)
Possible next subqueries
find
limit
equal
range
limit(value)
Required parameters
value
Provider.select('table').from('contract name').limit(1)
Possible next subqueries
find
index
equal
range
find()
Provider.select('table').from('contract name').find()
Last updated
Was this helpful?