Methods

loadKeys(privateKeys)

Load the private keys of the authority public keys in order to approve transactions with them

const account = await eoslime.Account.createRandom();

const keys = [
    await eoslime.utils.generateKeys(),
    await eoslime.utils.generateKeys()
]

await account.addOnBehalfKey(keys[0].publicKey)
await account.addOnBehalfKey(keys[1].publicKey)
await account.increaseThreshold(2);

const multiSigAccount = eoslime.MultiSigAccount.load(account.name, account.privateKey);
multiSigAccount.loadKeys(keys.map((key) => { return key.privateKey }));

loadAccounts(accounts)

Load the accounts configured to act on behalf of the multisignature authority

const account = await eoslime.Account.createRandom();
const accounts = await eoslime.Account.createRandoms(2);

await account.addOnBehalfAccount(accounts[0].name);
await account.addOnBehalfAccount(accounts[1].name);
await account.increaseThreshold(3);

const multiSigAccount = eoslime.MultiSigAccount.load(account.name, account.privateKey);
multiSigAccount.loadAccounts(accounts);

propose(contractAction, actionData)

Propose a transaction to be executed

Parameters

  1. contractAction - Instance of ContractFunction. ContractFunctions are all contract methods constructed with eoslime

     const faucetContract = eoslime.Contract.fromFile(FAUCET_ABI_PATH, faucetAccount.name, faucetAccount);
    
     // produce is a ContractFunction constructed from the contract ABI
     await faucetContract.actions.produce
  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

MultiSigAccount.load

When you are proposing a transaction, behind the scene the proposer approves it.

const proposer = await eoslime.Account.createRandom();
const onBehalfAccounts = await eoslime.Account.createRandoms(2);

await proposer.addOnBehalfAccount(onBehalfAccounts[0].name);
await proposer.addOnBehalfAccount(onBehalfAccounts[1].name);
await proposer.increaseThreshold(2);

const multiSigAccount = eoslime.MultiSigAccount.load(proposer.name, proposer.privateKey);
multiSigAccount.loadAccounts(onBehalfAccounts);

const proposalId = await multiSigAccount.propose(faucetContract.actions.produce, [account.name, "100.0000 TKNS", account.name, "memo"]);

approve(publicKey, proposalId)

Sign a proposed transaction

Parameters

  1. publicKey - publicKey of a loaded account/key

    const faucetContract = eoslime.Contract.fromFile(FAUCET_ABI_PATH, faucetAccount.name, faucetAccount);
    
    // produce is a ContractFunction constructed from the contract ABI
    await faucetContract.actions.produce
  2. proposalId - Response of the propose method

    const proposer = await eoslime.Account.createRandom();
    const onBehalfAccounts = await eoslime.Account.createRandoms(2);
    
    await proposer.addOnBehalfAccount(onBehalfAccounts[0].name);
    await proposer.addOnBehalfAccount(onBehalfAccounts[1].name);
    await proposer.increaseThreshold(2);
    
    const multiSigAccount = eoslime.MultiSigAccount.load(proposer.name, proposer.privateKey);
    multiSigAccount.loadAccounts(onBehalfAccounts);
    
    const proposalId = await multiSigAccount.propose(faucetContract.actions.produce, [account.name, "100.0000 TKNS", account.name, "memo"]);
    await multiSigAccount.approve(multiSigAccount.accounts[0].publicKey, proposalId);

processProposal(proposalId)

Broadcast proposal in case of enough approvals

const proposer = await eoslime.Account.createRandom();
const onBehalfAccounts = await eoslime.Account.createRandoms(2);

await proposer.addOnBehalfAccount(onBehalfAccounts[0].name);
await proposer.addOnBehalfAccount(onBehalfAccounts[1].name);
await proposer.increaseThreshold(2);

const multiSigAccount = eoslime.MultiSigAccount.load(proposer.name, proposer.privateKey);
multiSigAccount.loadAccounts(onBehalfAccounts);

const proposalId = await multiSigAccount.propose(faucetContract.actions.produce, [account.name, "100.0000 TKNS", account.name, "memo"]);
await multiSigAccount.approve(multiSigAccount.accounts[0].publicKey, proposalId);

/*
By doing propose, the proposer approves the transaction
In order the transaction to be executed it requires 2 signatures
because of the treshold. That is why we need only one approve
*/ 
const txReceipt = await multiSigAccount.processProposal(proposalId);

Last updated