Eoslime
Search…
Methods

loadKeys(privateKeys)

Load the private keys of the authority public keys in order to approve transactions with them
1
const account = await eoslime.Account.createRandom();
2
3
const keys = [
4
await eoslime.utils.generateKeys(),
5
await eoslime.utils.generateKeys()
6
]
7
8
await account.addOnBehalfKey(keys[0].publicKey)
9
await account.addOnBehalfKey(keys[1].publicKey)
10
await account.increaseThreshold(2);
11
12
const multiSigAccount = eoslime.MultiSigAccount.load(account.name, account.privateKey);
13
multiSigAccount.loadKeys(keys.map((key) => { return key.privateKey }));
Copied!

loadAccounts(accounts)

Load the accounts configured to act on behalf of the multisignature authority
1
const account = await eoslime.Account.createRandom();
2
const accounts = await eoslime.Account.createRandoms(2);
3
4
await account.addOnBehalfAccount(accounts[0].name);
5
await account.addOnBehalfAccount(accounts[1].name);
6
await account.increaseThreshold(3);
7
8
const multiSigAccount = eoslime.MultiSigAccount.load(account.name, account.privateKey);
9
multiSigAccount.loadAccounts(accounts);
Copied!

propose(contractAction, actionData)

Propose a transaction to be executed
Parameters
  1. 1.
    contractAction - Instance of ContractFunction. ContractFunctions are all contract methods constructed with eoslime
    1
    const faucetContract = eoslime.Contract.fromFile(FAUCET_ABI_PATH, faucetAccount.name, faucetAccount);
    2
    3
    // produce is a ContractFunction constructed from the contract ABI
    4
    await faucetContract.actions.produce
    Copied!
  2. 2.
    actionData - An array of the parameters you will want the produce function to be called with
You are loading actually the proposer account with
1
MultiSigAccount.load
Copied!
When you are proposing a transaction, behind the scene the proposer approves it.
1
const proposer = await eoslime.Account.createRandom();
2
const onBehalfAccounts = await eoslime.Account.createRandoms(2);
3
4
await proposer.addOnBehalfAccount(onBehalfAccounts[0].name);
5
await proposer.addOnBehalfAccount(onBehalfAccounts[1].name);
6
await proposer.increaseThreshold(2);
7
8
const multiSigAccount = eoslime.MultiSigAccount.load(proposer.name, proposer.privateKey);
9
multiSigAccount.loadAccounts(onBehalfAccounts);
10
11
const proposalId = await multiSigAccount.propose(faucetContract.actions.produce, [account.name, "100.0000 TKNS", account.name, "memo"]);
Copied!

approve(publicKey, proposalId)

Sign a proposed transaction
Parameters
  1. 1.
    publicKey - publicKey of a loaded account/key
    1
    const faucetContract = eoslime.Contract.fromFile(FAUCET_ABI_PATH, faucetAccount.name, faucetAccount);
    2
    3
    // produce is a ContractFunction constructed from the contract ABI
    4
    await faucetContract.actions.produce
    Copied!
  2. 2.
    proposalId - Response of the propose method
    1
    const proposer = await eoslime.Account.createRandom();
    2
    const onBehalfAccounts = await eoslime.Account.createRandoms(2);
    3
    4
    await proposer.addOnBehalfAccount(onBehalfAccounts[0].name);
    5
    await proposer.addOnBehalfAccount(onBehalfAccounts[1].name);
    6
    await proposer.increaseThreshold(2);
    7
    8
    const multiSigAccount = eoslime.MultiSigAccount.load(proposer.name, proposer.privateKey);
    9
    multiSigAccount.loadAccounts(onBehalfAccounts);
    10
    11
    const proposalId = await multiSigAccount.propose(faucetContract.actions.produce, [account.name, "100.0000 TKNS", account.name, "memo"]);
    12
    await multiSigAccount.approve(multiSigAccount.accounts[0].publicKey, proposalId);
    Copied!

processProposal(proposalId)

Broadcast proposal in case of enough approvals
1
const proposer = await eoslime.Account.createRandom();
2
const onBehalfAccounts = await eoslime.Account.createRandoms(2);
3
4
await proposer.addOnBehalfAccount(onBehalfAccounts[0].name);
5
await proposer.addOnBehalfAccount(onBehalfAccounts[1].name);
6
await proposer.increaseThreshold(2);
7
8
const multiSigAccount = eoslime.MultiSigAccount.load(proposer.name, proposer.privateKey);
9
multiSigAccount.loadAccounts(onBehalfAccounts);
10
11
const proposalId = await multiSigAccount.propose(faucetContract.actions.produce, [account.name, "100.0000 TKNS", account.name, "memo"]);
12
await multiSigAccount.approve(multiSigAccount.accounts[0].publicKey, proposalId);
13
14
/*
15
By doing propose, the proposer approves the transaction
16
In order the transaction to be executed it requires 2 signatures
17
because of the treshold. That is why we need only one approve
18
*/
19
const txReceipt = await multiSigAccount.processProposal(proposalId);
Copied!
Last modified 1yr ago