0

I send a message from contract to an EOA by this Solidity code:

function sendByte(address EOA, bytes memory byteData) external{
        EOA.call("0x416c6972657a61204b69616b6f6a6f757269");
    }

Now, How can I see/get the sent message from the generated transaction? Is there a method of web3js or web3py for doing that?

This is the transaction that Truffle console provides:

{
  tx: '0x5d07278838b93ba5e2eb12e12e5bf20353ed976b5cd43c935d38dd2b147d79d3',
  receipt: {
    transactionHash: '0x5d07278838b93ba5e2eb12e12e5bf20353ed976b5cd43c935d38dd2b147d79d3',
    transactionIndex: 0,
    blockHash: '0x156851759ad78d1b4f94adfdd157c2f1c75cec450e75fa5fa72899cc9abcc2c0',
    blockNumber: 33,
    from: '0xcf247b4a6313aacdb23c7627482d4902d832ef3c',
    to: '0x489a7bb654752b1a7296339019b9ff6b7759fe1b',
    gasUsed: 23453,
    cumulativeGasUsed: 23453,
    contractAddress: null,
    logs: [],
    status: true,
    logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
    rawLogs: []
  },
  logs: []
}

1 Answer 1

0

Yes, You can get the message by emitting an event and looking at the "logs["data"]" field in the transaction receipt (e.g. from truffle console) in your question.

contract Test {
    event Message(address indexed receiver, bytes data);
    function sendByte(address EOA, bytes memory byteData) external{
        emit Message(EOA, byteData);
        EOA.call(byteData);
    }
}

As mentioned in my other answer, the way you call like this wont affect the EOA address, it only has some effect on your own contract (e.g. emitting event logs).

2
  • So, There is no way to get message by .call(), yes? So why should we use .call(<message>)?
    – Alireza
    Commented Jan 4, 2023 at 16:26
  • we dont need to use .call(message). Depends on your application (I guess you want to implement some messaging app between EOA address ? It should be done with a smart contract but more complex than this.
    – minhhn2910
    Commented Jan 5, 2023 at 1:49

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.