1

what is the reciptId section in the data section. How can you include it in a transaction? new to ethereum so sorry if this is a stupid question. I would like to include the name of a person in the receiptid section ... is that possible

1
  • This is very transaction-specific. Can you include an example?
    – 0xSanson
    Sep 3 at 21:28

1 Answer 1

0

By receiptId, are you referring to the receipt of a transaction? If so, we cannot put custom data in a transaction.

If you are referring to a contract event/log, then if the contract allows to send a custom string to be added into an event and emit it, then it could be done.

For example, in the following simple contract, the function sendPayment acts as an intermediate between two parties, one that wants to send some eth to the other and log some custom data into an event:

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.6;

contract Contract {

    event Payment(address indexed from, address indexed to, string recipientName);

    function sendPayment(address from, address payable to, string memory recipientName) public payable {
        to.transfer(msg.value);
        emit Payment(from, to, recipientName);
    }
}

If needed, we could add more custom data to the Payment event and accept it in the sendPayment function and emit the event with that data.

Then, with the sender or recipient address, we could query the blockchain and get the event and read the custom data in it.

We could also query that event with the transaction hash.

This is one of the uses of smart contracts, to extend the functionality of the blockchain.

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.