Eoslime
Search…
Blockchain Contract Action Methods
Each blockchain contract function has some additional functionality you can find very useful

action.getRawTransaction(params, ?options)

Construct raw transaction for an action
1
const faucetContract = eoslime.Contract.fromFile(FAUCET_ABI_PATH, faucetAccount.name, faucetAccount);
2
3
const rawFunctionTx = await faucetContract.actions.produce.
4
getRawTransaction([myAccount.name, '100.0000 TKNS']);
5
6
/*
7
rawFunctionTx =
8
{
9
expiration: '2019-11-12T15:19:15',
10
ref_block_num: 24381,
11
ref_block_prefix: 3641461961,
12
max_net_usage_words: 0,
13
max_cpu_usage_ms: 0,
14
delay_sec: 0,
15
context_free_actions: [],
16
actions:
17
[ { account: 'l3ac5afc1334',
18
name: 'produce',
19
authorization: [Array],
20
data:
21
'20d458628c150e8940420f000000000004544b4e530000000c6c6532353331343433636335046d656d6f' } ],
22
transaction_extensions: []
23
}
24
*/
Copied!
The options one can provide here are the same as the ones for the contract actions
1
const faucetContract = eoslime.Contract.fromFile(FAUCET_ABI_PATH, faucetAccount.name, faucetAccount);
2
3
const rawFunctionTx = await faucetContract.actions.produce.
4
getRawTransaction([myAccount.name, '100.0000 TKNS'], { unique: true });
Copied!

action.sign(params, ?options)

Sign action and return a ready-to-broadcast transaction
1
const faucetContract = eoslime.Contract.fromFile(FAUCET_ABI_PATH, faucetAccount.name, faucetAccount);
2
3
const signedFunctionTx = await faucetContract.actions.
4
produce.sign([myAccount.name, '100.0000 TKNS']);
5
6
/*
7
signedActionTx =
8
{
9
compression: 'none',
10
signatures:
11
[ 'SIG_K1_K7nuuRW3LTzcjwjot6BStnSKj4cmdgNBp8yXsqJuAxTTrRiLEGmA253JBPLt6pNL4XWopJrA3UrhXWnLDcB3XAmYR25J9j'],
12
transaction:
13
{
14
expiration: '2019-11-12T15:22:38',
15
ref_block_num: 24786,
16
ref_block_prefix: 24901427,
17
max_net_usage_words: 0,
18
max_cpu_usage_ms: 0,
19
delay_sec: 0,
20
context_free_actions: [],
21
actions: [ [Object] ],
22
transaction_extensions: []
23
}
24
}
25
*/
Copied!
The options one can provide here are the same as the ones for the contract actions
1
const faucetContract = eoslime.Contract.fromFile(FAUCET_ABI_PATH, faucetAccount.name, faucetAccount);
2
3
const rawFunctionTx = await faucetContract.actions.produce.
4
sign([myAccount.name, '100.0000 TKNS'], { from: ANOTHER_ACCOUNT });
Copied!

Events

processed

You can process some logic every time a contract function is broadcasted to the chain
1
const faucetContract = eoslime.Contract.fromFile(FAUCET_ABI_PATH, faucetAccount.name, faucetAccount);
2
3
faucetContract.produce.on('processed', (txReceipt) =>
4
{
5
// do some custom logic
6
}
7
);
8
Copied!
Last modified 1yr ago