1

I'm tying to send a token to an address using ethers.js and here is my code:

contract.transfer(address , amount)

I want to send additional data like "helloworld" to this function to use it later. I tried this:

contract.transfer(address , amount , {
data: "helloworld"
})

but it gives me error:

cannot override "data"

is it possible to do this? how can I send the data? or is there a way to save additional data to blockchain using one transaction? note: the transfer function is from BUSD token

2 Answers 2

1

The transfer function you're using likely doesn't have a data field. You need to assign a data input or use a function that either stores the data or emits it an event to store in order to "keep" the data on the blockchain.

Assign metadata to a transaction

2
  • but i'm using a deployed contract. i'm working with BUSD token contract and i cant change it. is there any way to send data to it? i want to use it off-chain?
    – Meysam
    Aug 15, 2022 at 14:13
  • not really a way to do this in the EVM unfortunately
    – thefett
    Aug 15, 2022 at 15:15
0

You can either use

2
  • because i'm using a deployed contract i cant use erc777. i'm using BUSD token contract and it's erc20. for second one i'm not using that because it's not safe it's possible that when user approves my contract after that the user empty his account and i won't have a chance to use transferfrom function.
    – Meysam
    Aug 15, 2022 at 14:18
  • I think you have a misunderstanding how approve() and transferFrom() works. Please read xyproblem.info, edit your questions and add more background and context what you are doing and why and then we can give you a better answer. Aug 15, 2022 at 15:16

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.