ecadlabs / taquito

A library for building dApps on the Tezos Blockchain - JavaScript / TypeScript
https://taquito.io
Apache License 2.0
298 stars 116 forks source link

Tezos.estimate.transfer got 400 #363

Closed RuChiang closed 1 year ago

RuChiang commented 4 years ago

Hi there,

I'm trying to estimate the fees for my transfer transaction, and this is what I did

Tezos.setProvider({ rpc: rpcNode, signer: new SomeSigner(publicKey) });
let pkh = await Tezos.signer.publicKeyHash();
let est = await Tezos.estimate.transfer({ amount, to: toAddr, source: pkh });

and I kept getting this error

HttpResponseError {
  message: 'Http error response: (400) Failed to parse the request body: No case matched:\n' +
    '  At /kind, unexpected string instead of endorsement\n' +
    '  At /kind, unexpected string instead of seed_nonce_revelation\n' +
    '  At /kind, unexpected string instead of double_endorsement_evidence\n' +
    '  At /kind, unexpected string instead of double_baking_evidence\n' +
    '  At /kind, unexpected string instead of activate_account\n' +
    '  At /kind, unexpected string instead of proposals\n' +
    '  At /kind, unexpected string instead of ballot\n' +
    '  At /kind, unexpected string instead of reveal\n' +
    '  At /destination:\n' +
    '    Unhandled error (Failure "Invalid contract notation.")\n' +
    '  At /kind, unexpected string instead of origination\n' +
    '  At /kind, unexpected string instead of delegation',
  status: 400,
  statusText: 'Bad Request',
  body: 'Failed to parse the request body: No case matched:\n' +
    '  At /kind, unexpected string instead of endorsement\n' +
    '  At /kind, unexpected string instead of seed_nonce_revelation\n' +
    '  At /kind, unexpected string instead of double_endorsement_evidence\n' +
    '  At /kind, unexpected string instead of double_baking_evidence\n' +
    '  At /kind, unexpected string instead of activate_account\n' +
    '  At /kind, unexpected string instead of proposals\n' +
    '  At /kind, unexpected string instead of ballot\n' +
    '  At /kind, unexpected string instead of reveal\n' +
    '  At /destination:\n' +
    '    Unhandled error (Failure "Invalid contract notation.")\n' +
    '  At /kind, unexpected string instead of origination\n' +
    '  At /kind, unexpected string instead of delegation',
  name: 'HttpResponse'
}

Seems the error came from

let est = await Tezos.estimate.transfer({ amount, to: toAddr, source: pkh });

I was suspecting it could be the problem with the rpc node, but apparently my rpc node is working as

let contract = await Tezos.rpc.getContract(pkh);

actually returns a value

Has anyone also run into this error? Many thanks if any assistance is offered

0xRafal commented 4 years ago

It seems Estimate API expects amount in Tezos while Transfer in Mutez, so if you pass Mutez you get error with insufficient funds.

jevonearth commented 3 years ago
michaelkernaghan commented 1 year ago

reviewed - 2023-04-26 could no longer reproduce the problem

michaelkernaghan commented 1 year ago

const amount = 2; const address = 'tz1h3rQ8wBxFd8L9B3d7Jhaawu6Z568XU3xY';

// Estimate gasLimit, storageLimit and fees for a transfer operation const est = await tezos.estimate.transfer({ to: address, amount: amount }) console.log(est.burnFeeMutez, est.gasLimit, est.minimalFeeMutez, est.storageLimit, est.suggestedFeeMutez, est.totalCost, est.usingBaseFeeMutez)

result: 0 1101 300 0 400 300 300