2

I am trying to estimate the fees for a transaction call using the Tezos.estimate.transfer() function but it is asking to initialize a signer. Is it possible to make an estimate call without a signer or private key?

8
  • Does this answer your question? How does tezos-client compute a transaction fee?
    – utdrmac
    Commented Nov 12, 2020 at 14:21
  • @utdrmac not exactly, I know the rpc endpoint to make the query. But I am looking for a solution to do this with taquito. Commented Nov 12, 2020 at 15:55
  • tezos.stackexchange.com/questions/2733/…
    – utdrmac
    Commented Nov 12, 2020 at 22:34
  • This question has been asked many times. Please use the search feature.
    – utdrmac
    Commented Nov 12, 2020 at 22:34
  • 1
    Thanks @utdrmac for pointing out these resources, but I have to disagree, there are surely question on how to calculate tx fee. But what I am looking for is specific to this npm package called Taquito. None of the answers provide the solution I am looking. I guess I will have to use the raw rpc calls directly. Commented Nov 13, 2020 at 1:43

1 Answer 1

0

I guess the below code will help you.

const TezosToolkit = require('@taquito/taquito').TezosToolkit;
const tezos = new TezosToolkit("TEZOS NODE RPC URL");
const InMemorySigner = require('@taquito/signer').InMemorySigner;

const estimateTxn = async function(input){
    tezos.setProvider({ signer: new InMemorySigner(input.senderPrivateKey) });
    const estimated = await tezos.estimate
                .transfer({ to: input.destination, amount: Number(input.amount)/1000000 })
                .then((est) => {
                    const estimated = {
                        "gasLimit"     :   est.gasLimit.toString(),
                        "storageLimit" :   est.storageLimit.toString(),
                        "suggestedFee" :   est.suggestedFeeMutez.toString()
                    }
                    return estimated;
                })
                .catch((error) => {
                    console.log("ERROR: Estimation failed!!",error);
                });
    return estimated;
}

Here the input is:

const input = {
    "destination"       :   "address of receiver",
    "amount"            :   "amount in tez",
    "source"            :   "address of sender",
    "senderPublicKey"   :   "public key of sender",   
    "senderPrivateKey"  :   "private key of sender"
}
1
  • The question specifically mentions that I want to estimate the tx fees without initializing the signer, please read the question before providing an answer. Thanks Commented Dec 4, 2021 at 3:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.