How can I get a gasFee estimate for a transaction of my custom contract?
For a normal transaction execution from the SPL library I can do so like this:
import { Transaction } from '@solana/web3.js';
const transaction = new Transaction({
recentBlockhash: recentBlockhash.blockhash,
feePayer: wallet.publicKey
}).add(
// someFunctionCall
);
const estimatedGas = await transaction.getEstimatedFee(connection);
But I do not use new Transaction()
to call my custom Program's methods. It's done like:
const tx = await program.methods
.myCustomMethod(...)
.accounts(...)
.rpc();
How can I estimate the gas for the tx
w/o actually calling it?