0

What is the recommended way to call the Solidity fallback() function with Ethers.js ? https://docs.soliditylang.org/en/v0.8.0/contracts.html#fallback-function

Om Solari
  • 207
  • 1
  • 4
  • 13

1 Answers1

2

You can send an empty transaction

let tx = {
    to: contractAddress
};

await signer.sendTransaction(tx);
Petr Hejda
  • 40,554
  • 8
  • 72
  • 100
  • How to get response data from sendTransaction? var x = await signer.sendTransaction(tx); --> just returns big object with no response data? – Om Solari Apr 24 '21 at 03:03
  • It doesn't return the "contract function return value" when you're creating a transaction. But within the fallback function, you can set a property or emit an event, and that will be accessible using Ethers.js. See my answer to your other question - https://stackoverflow.com/a/67240956/1693192. – Petr Hejda Apr 24 '21 at 08:57