3

I have a simple smart-contract that holds user funds and that can be withdrawn by sending a signed message.

However, I would like to offer the possibility for users to anticipate the fees they have to pay everytime they send funds to the contract.

I can properly call the contract with the taquito library by using the contract abstraction object:

const operation = await contract.methods
        .feedUserAccount(this.tezosAddress)
        .send({ amount });

However, when I test it with the EstimationProvider class, I get a TezosOperationError:

try{
    const e = await Tezos.contract.at("KT1KBhwoSeqJt26oK8yjubTfdSgDuaVC87xR");
    const o = await Tezos.estimate.transfer({ 
      to: "KT1KBhwoSeqJt26oK8yjubTfdSgDuaVC87xR", 
      amount: 1,
      source: "tz1wWzjK62ft3jufvrua6zfT3sLVmo7776kq",
      parameter: {
        entrypoint: 'feedUserAccount',
        value: {prim:"Left",args:[{prim:"Left",args:[{prim:"Right",args:[{string:"tz1wWzjK62ft3jufvrua6zfT3sLVmo7776kq"}]}]}]}
      }
    });
    console.log(o.suggestedFeeMutez);

Error message:

TezosOperationError {
  errors: 
   [ { kind: 'permanent',
       id: 'proto.005-PsBabyM1.michelson_v1.bad_contract_parameter',
       contract: 'KT1KBhwoSeqJt26oK8yjubTfdSgDuaVC87xR' },
     { kind: 'permanent',
       id: 'proto.005-PsBabyM1.invalidSyntacticConstantError',
       location: 0,
       expectedForm: [Object],
       wrongExpression: [Object] },
     { kind: 'permanent',
       id: 'proto.005-PsBabyM1.invalidSyntacticConstantError',
       location: 0,
       expectedForm: [Object],
       wrongExpression: [Object] },
     { kind: 'permanent',
       id: 'proto.005-PsBabyM1.invalidSyntacticConstantError',
       location: 0,
       expectedForm: [Object],
       wrongExpression: [Object] },
     { kind: 'permanent',
       id: 'proto.005-PsBabyM1.invalidSyntacticConstantError',
       location: 0,
       expectedForm: [Object],
       wrongExpression: [Object] },
     { kind: 'permanent',
       id: 'proto.005-PsBabyM1.michelson_v1.invalid_expression_kind',
       location: 0,
       expected_kinds: [Array],
       wrong_kind: 'primitiveApplication' } ],
  name: 'TezosOperationError',
  id: 'proto.005-PsBabyM1.michelson_v1.invalid_expression_kind',
  kind: 'permanent',
  message: '(permanent) proto.005-PsBabyM1.michelson_v1.invalid_expression_kind' }

The feedUserAccount expects a key_hash and I generated the value parameter with SmartPY explorer. But I can't make it work, is it the library or the way I generate the query?

The babylonet contract can be found at this address: KT1KBhwoSeqJt26oK8yjubTfdSgDuaVC87xR

  • Sorry, I'm not an export on taquito. Do you have any reference to the documentation of the estimator? Do you know if there is a way of running taquito in a debugging mode, so that the underlying RPC calls are visible? That would help to understand the error you receive. – arvidj Feb 4 at 18:56
  • From the tezos-dev slack, #taquito: "if your script runs in the browser, you can use the browser’s debugging console/network tab". I think this output could help to diagnose your error. – arvidj Feb 4 at 19:13
2

You can call toTransferParams({amount: 5}) on the method you want to estimate, and pass that result to Tezos.estimate.transfer()

The results of which will look something like:

Estimate {
  _gasLimit: 66993,
  _storageLimit: 0,
  opSize: 216,
  baseFeeMutez: 100
}

Full example:

Tezos.contract.at('KT1KBhwoSeqJt26oK8yjubTfdSgDuaVC87xR'))
.then(contract => {
    const amt = 5
    return contract.methods
       .feedUserAccount('tz3WQjEGvpjnb6h6h8zmrFmhzeEzXSDddz6H')
       .toTransferParams({amount: 5});
    })
.then(tx => {
    console.log(tx)
    return Tezos.estimate.transfer(tx)
})
.then(est => console.log(est))
.catch(error => console.log(error))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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