a user send 10 ethers to Smart Contract A, then Smart Contract A send 10 ethers to Smart Contract B.
Would that be 2 transactions, or 1 transactions?
(What I heard is that the answer is 1, why is that?)
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityIt's one transaction.
Transactions are..well, transactional. Either everything succeeds or everything is rolled back (with some exception, noted below). It's all done in one transaction.
If you initiate a transaction to some contract you may not even know what the contract does. Maybe it contacts another contract or ten different contracts - it does not matter what it does because everything is encapsulated within the same transaction. And no matter what happens, you (the sender) pay for it all because you initiated the transaction.
Nodes have to be able to process the whole transaction. If something goes wrong (maybe a require
fails or the transaction runs out of gas) the whole transaction is typically reverted. Only if some lower-level contract calls fail it may not result in the whole transaction being reverted but only that specific call being reverted within the transaction - depending on implementation.
require
fails or the transaction runs out of gas) the whole transaction is reverted." This isn't completely true. The EVM doesn't stipulate anything about a child call reverting making the entire transaction revert, it only reverts its call. Of course Solidity bubbles these up unless you do lower level calls that return true/false instead of reverting on failure.
May 18, 2018 at 3:03