3

I wondered if "transfer()" function is a call or a transaction.

We know contracts only send messages, not transactions.

If a DAO-like contract has a variable and a threshold when the variable reaches the threshold the contract automatically transfer some Ether to an account.

Question: Is this transfer of Ether (done using transfer()) a message or transaction?

In general, I'd like to know how transferring Ether from a contract account to someone is described in terms of a transaction/message.

4

Ethereum transactions are also messages. The difference is that transactions are signed messages, because they were signed by a human with a private key.

Ethereum contracts create 'unsigned messages' and humans create 'signed messages'.

When a contract calls .send() or .transfer(), it can transfer some amount of Ether. This is an unsigned message, but it is also called an 'internal transaction'. An example:

https://etherscan.io/tx/0x3f50e8b755fdefceb2dad2854424211c3c1f8a8b085160c5be5c46d57c2ec183#internal

In this transaction, the human owner of 0xc459... called a function in contract 0xe70b... by creating a signed message. Then, the contract called .send() to create an unsigned message to transfer some Ether to 0xc459....

Signed messages are stored physically in the blockchain, on the hard drives of Ethereum nodes. Unsigned messages are not necessarily stored, they are implied by the execution flow of a contract function call.

In conclusion:

Signed messages are 'transactions' and are created by humans

Unsigned messages are 'internal transactions' and are created by contracts using a function call

  • Thanks for the answer, but it raises some other question: In my example, if the internal transactions are not included in the blockchain, then how the Ether balance of contract will be reduced and the recipient Ether balance increases? – Ay. Sep 29 '17 at 14:35
  • @AdrianAd, Every Ethereum node which follows the blockchain from the start, will follow the execution flow of each contract function call. They will all come to the same conclusion: that an internal transaction must take place, that the balance of the contract must be reduced and the balance of the recipient increased. After the balances have been updated, there's not necessarily any need to remember how they were updated. – Jesse Busman Sep 29 '17 at 14:40
  • Yes, thanks! It'd be great to add somewhere to your answer for others who read it. Cheers! – Ay. Sep 29 '17 at 14:42
  • I wondered if the internal transaction can change sate of a contract? – Ay. Sep 30 '17 at 10:36
0

Yes, an internal transaction (message call) definitely can change a state of contract. you also can specify gas limit by add .gas() after the function name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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