As we all know that an external account can send a transaction to smart contract. But I'm confused when it comes to how contracts talk with each other.

Contracts that exist within the global scope of Ethereum’s state can talk to other contracts within that same scope. The way they do this is via “messages” or “internal transactions” to other contracts. We can think of messages or internal transactions as being similar to transactions, with the major difference that they are NOT generated by externally owned accounts. Instead, they are generated by contracts. They are virtual objects that, unlike transactions, are not serialized and only exist in the Ethereum execution environment.1

I fully understand what it mean in the quote. But my question is HOW ? Are there some examples of smart contracts in Solidity show how contracts communicate with each other via "message"?

bumped to the homepage by Community yesterday

This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

  • Whenever a smart contract calls a function in another smart contract, it does so via a 'message'. – Jesse Busman Nov 30 '18 at 22:16
  • To add to Jess answer, I would say that the fact that contracts communicate via "message" is just a low-level detail from the point of view of a smart contract developer. – Julien Klepatch Dec 2 '18 at 13:03

Here's a simple Solidity example:

contract One {
    function callme() external {
        // ...

contract Two {
    // This function accepts as a parameter the address for a deployed
    // instance of the One contract.
    function callOne(One one) external {
        // call the function callme() on our instance of One

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.