How to estimate the price of Gas prior to submitting a transaction on ethers?

Cryptocurrency News and Public Mining Pools

How to estimate the price of Gas prior to submitting a transaction on ethers?

I am trying to estimate gas using ethers. I have tred using await this.signer.getGasPrice() but this doesn't take into account my contract's function and my address.I saw that on ethers's documentation they have a function

await provider.estimateGas({ // Wrapped ETH address

to: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // `function deposit() payable`

data: "0xd0e30db0", // 1 ether

value: parseEther("1.0") });

but this takes transaction data as an input?

How am I supposed to get tranaction data prior to submitting a transaction?

submitted by /u/pepeman931
[link] [comments]