consteoslime=require('eoslime').init();// Existing accounts on local networklet payer =eoslime.Account.load('myAcc1','myPrivateKey1');let account2 =eoslime.Account.load('myAcc2','myPrivateKey2');// Payer will buy ram for account2awaitaccount2.buyRam(1000, payer);
buyBandwidth (cpu, net, ?payer)
Buy cpu and network for this account
Defaults/Optionals:
payer - current account
consteoslime=require('eoslime').init();// Existing accounts on local networklet payer =eoslime.Account.load('myAcc1','myPrivateKey1');let account2 =eoslime.Account.load('myAcc2','myPrivateKey2');// Payer will buy cpu and network for account2 for 100 EOS awaitaccount2.buyBandwidth('100.0000 EOS','100.0000 EOS', payer);
send (receiver, amount, symbol)
Send tokens to another account
Defaults/Optionals:
symbol - EOS
consteoslime=require('eoslime').init();// Existing accounts on local networklet sender =eoslime.Account.load('myAcc1','myPrivateKey1');let receiver =eoslime.Account.load('myAcc2','myPrivateKey2');// The sender will send 100 EOS tokens to receiverawaitsender.send(receiver,`100.0000`,'EOS');
addAuthority (authorityName, ?threshold)
Creates a new authority and add current account public key in it
Defaults/Optionals:
threshold - 1
consteoslime=require('eoslime').init();// Existing account on local networkconstactiveAccount=eoslime.Account.load('myAcc1','myPrivateKey1','active');// It will create 'custom' authority. Parent authority will be the 'active' oneawaitactiveAccount.addAuthority('custom',2);
setAuthorityAbilities(authority, abilities)
Once you add a sub authority, it can not process whatever transaction. You should define what actions of which contracts the authority has permissions to execute.
Parameters
authority - The name of the authority the abilities will be applied to
It is useful when you have multiple keys or accounts operating from an authority. This method will allow you to prepare a multisignature account.
constTHRESHOLD=2;constaccount=awaitAccount.createRandom();constkeysPair=awaiteoslime.utils.generateKeys();// Add one more key to authorityawaitaccount.addAuthorityKey(keysPair.publicKey);// Once threshold being increased, // both keys should sign the transaction in order to be broadcastedawaitaccount.increaseThreshold(THRESHOLD);
addPermission (permission, ?weight)
Add permission to authority such as eosio.code
Defaults/Optionals:
weight - 1
Adding eosio.code permission would result in
consteoslime=require('eoslime').init();// Existing accounts on local networklet account =eoslime.Account.load('myaccount','myPrivateKey','active');let tokenFactoryAccount =eoslime.Account.load('tokenfactory','factoryPrivateKey','active');/* It will allow a contract account with eosio.code permission to act on behalf when you are authorizing an action with active authority Use case: We have two contracts: TokenFactory and Token TokenFactory.create behind the scene calls Token.issue_tokens. issue_tokens caller will be the TokenFactory. However you could want your account to be forwarded to issue_tokens instead of TokenFactory's one*/awaitaccount.addPermission('eosio.code');
consteoslime=require('eoslime').init();// Existing account on local networklet account =eoslime.Account.load('myAcc1','myPrivateKey1');// custom.token is a contract account with a token deployed on itawaitaccount.getBalance('CUSTOM',custom.token);