2

Can't find any good documentation on creating a raw transaction with contract data in ethers.js. The equivalent in web3 is adding the encodeABI on the data property. Any guidance on this?

This isn't working:

data = myContract.interface.functions.myFunction(value);
const tx = {
   ...
   data
   ...
}

It doesn't seem to recognize this is a function (even though i see the data property there).

1

You can use the populateTransaction mechanism documented here: https://docs.ethers.io/v5/api/contract/contract/

So specifically, that'd be:

const data = await myContract.populateTransaction.myFunction(value);
0

Can you tell me about how get contract function return data by using ethers.js to connect smart contract, Please! Thank you very much.

1
  • If you have another question, open a new post and be specific about your problem. – Florian Castelain Apr 27 at 9:50

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.