eos icon indicating copy to clipboard operation
eos copied to clipboard

what does an action called my multisig contract looks like?

Open breadbread1984 opened this issue 8 years ago • 3 comments

can an action called by multisig contract have multiple require_auth() asking distinct participant's authority?

breadbread1984 avatar Jun 13 '18 02:06 breadbread1984

The contract code handling an action can call require_auth multiple times with different accounts required. That means that the authorizations for that action need to include all of the required accounts (at appropriate permission levels) necessary to satisfy the require_auths of that action handler.

That is completely separate from the purpose of the eosio.msig contract, which I will get to momentarily.

With one important exception, all transactions must satisfy the permissions mapped to by the authorizations included in a transaction. The typical way of satisfying these authorizations is through signatures attached to the signed transaction. Users can create a transaction and add signatures to it as necessary until the required signatures are achieved, at which point the fully signed transaction can be broadcast into the network and eventually (assuming the signatures are valid and sufficient) be included into the blockchain.

The eosio.msig contract provides a more convenient way of doing this on-chain rather than requiring coordination among the various signers off-chain. I mentioned earlier that there is one important exception to the need for a transaction to satisfy the permissions mapped to by the authorizations included in a transaction. That exception is when a contract deployed on a privileged account (and the eosio.msig account is privileged on recommended deployments of EOSIO chains along with eosio) sends the transaction as a deferred transaction, which is exactly what the eosio.msig::exec action does with proposed transactions. However, prior to sending the transaction it ensures that all the provided approvals of the proposes transaction satisfy the required authorizations of the transaction (not because it needs to, but because this self-imposed restriction makes the contract safe to allow anyone to use).

So if you want to use the eosio.msig to propose, approve, and ultimately execute a transaction containing an action that when executed requires several authorizations to be satisfied, you can do so by:

  1. ensuring that the transaction to be proposed has the required authorizations included in the authorization field of the action;
  2. using the eosio.msig::propose action to propose that transaction along with all the relevant permission_levels that can satisfy the included authorizations of the transaction;
  3. waiting until all required actors approve the proposed transaction using the eosio.msig::approve action;
  4. and finally, executing the proposed transaction using eosio.msig::exec once all the necessary approvals have been collected.

arhag avatar Jun 13 '18 02:06 arhag

thx for the prompt reply!

breadbread1984 avatar Jun 13 '18 06:06 breadbread1984

@arhag i want to implement an action to do trading between virtual items in dApp and SYS coin. so i need authorities of both buyer and seller. is the right way to do it creating a new authority with threshold of 2? so that any transaction will ask both involver to give authority to fulfill the requirement. If that is right, how can i call the action? shall call it through multisig in this case?

GeneSourceCode avatar Jun 14 '18 22:06 GeneSourceCode