3

Given two contracts, I'd like to push a transaction that requires successful completion of an action by each of the two contracts.

If either action by either contract fails then all actions by all contracts must not occur.

The transaction is successful only when all actions by all contracts are successful.

Is this possible? Please give an example using cleos.

1
  • Constructing complex cases (e.g. multiple actions) using cleos is painful right now. It's easier using eosjs or eos-altjs. May 9, 2018 at 21:25

2 Answers 2

4

In EOS, you can construct Transactions that contain multiple actions. When the transaction is submitted, all of the actions must succeed, or the entire transaction will fail. An example is available in the Smart Contract tutorial on the EOS Wiki.

1

If you're talking about contracts talking to one another, see the link here:

https://github.com/eoscanada/shine/blob/master/contract/shine.cpp#L96-L97

In this example, you see an "inline transactions" being sent. That one will be processed by the other contract. They all need to succeed for the transaction to be accepted.

In the shine contract.. we "listen" on a transfer to the account holding the shine code, and we "fan out" a series of transfers out.. I think this is not possible on some other well-known blockchains.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.