ethers.js
ethers.js copied to clipboard
Computing L1 + L2 fees on Base and Manta
Ethers Version
6.11.1
Search Terms
yes
Describe the Problem
When I use the method getTransactionReceipt to fetch the transaction by hash, the value of the fee for the transaction is not the same as the value of the fee that I get when I look it up in the blockchain browser directly
For example 0x10674dff8d304e3b49e50a7a5dd43470d2fd782a9a297062be043ea74f519151 The fee for this transaction is 0.00000589436349832 ETH, but in the blockchain browser it is 0.000006060525121534 ETH
why is that? Is there a good solution?
Code Snippet
protected async getTransactionFee(
transactionReceipt: TransactionReceipt,
): Promise<string> {
return transactionReceipt.fee.toString(10);
}
const testTransaction = await rpcClient.getTransactionReceipt(
'0x10674dff8d304e3b49e50a7a5dd43470d2fd782a9a297062be043ea74f519151',
);
console.log('testTransaction: ', testTransaction.fee.toString());
Contract ABI
No response
Errors
No response
Environment
node.js (v12 or newer)
Environment (Other)
No response
What network is this tx on? So that I can compare myself… :)
What network is this tx on? So that I can compare myself… :)
It's Manta, the network. Base has the same problem.
Do you have a public endpoint I can use?
If it is similar to Base, my guess may be the discrepancy between L1 and L2 (and therefore L1 + L2) fees; since the .fee can only determine the native fees (in this case, that would be L2).
You can probably use the Ethers Optimism library to get the total fees, if it uses the same Oracle address. If it doesn't I can update the library to accept an Oracle address. Let me know.
Yes,your guess is right, .fee get the L2 fees in this case,
So I'll just have to use the Ethers Optimism library to solve this problem? Thanks for the reply.