0

Does taquito have a way to parse the parameters of the entry-point in an operation? For Example:

"parameters":{
  "entrypoint":"do_transfer",
  "value":[
    {
      "prim":"Pair",
      "args":[
        {
          "bytes":"0000d0bf37609c311a6583a098ce2dbd590732d464b1"
        },
        [
          {
            "prim":"Pair",
            "args":[
              {
                "bytes":"000096bb5d1bcc69811fed7b1aabba544418a673a3e9"
              },
              {
                "prim":"Pair",
                "args":[
                  {
                    "int":"0"
                  },
                  {
                    "int":"200"
                  }
                ]
              }
            ]
          }
        ]
      ]
    }
  ]
}
0

2 Answers 2

0

Use @taquito/michelson-encoder

The Michelson-Encoder package aims to create an abstraction over the Michelson Language. It allows converting Michelson data into javascript-looking objects which are easier to use and reason about. Its integration into the main Taquito package makes it easier to write the storage when deploying a contract and the parameter when calling a contract entry-point or executing a view. It also provides an abstraction on the storage read value of the contract. The Schema class is intended to represent the contract storage, while the ParameterSchema represents its entry points. The Execute method takes a parameter in Michelson format and converts it into the JavaScript abstraction. The Encode method does the opposite; it takes a JavaScript object as a parameter and converts it into Michelson data.

const data = storageSchema.Execute(dataMichelson);
console.log(data);

/* output:
{
  "stored_counter": "10",
  "threshold": "5",
  "keys": [
    "edpkvS5QFv7KRGfa3b87gg9DBpxSm3NpSwnjhUjNBQrRUUR66F7C9g",
    "edpkuLxx9PQD8fZ45eUzrK3BhfDZJHhBuK4Zi49DcEGANwd2rpX82t"
  ]
} 
*/
0

.toTransferParams() can be helpful in this case.

Something like

      const contract = await Tezos.contract.at('KT1...')
      const inspect =  contract.methods.default([...]).toTransferParams()
      console.log(inspect.parameter)

Here's a link to live code example on the website. https://tezostaquito.io/docs/complex_parameters/#inspect-parameter

If it's not what you're looking for feel free to give us more context to help you further.

Your Answer

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