Search code examples
nearprotocol

How can I decode function call argument?


I got a function call below as result of calling txStatus in near-api-js. How can I decode function call argument to plain JSON same as in NEAR explorer?

{
    FunctionCall: {
      method_name: 'withdraw_reward',
      args: 'eyJ0b2tlbl9pZCI6InNuYWlsY29pbi5zbmFpbHNfZmkudGVzdG5ldCIsImFtb3VudCI6IjY2ODM2OTk4NDcxMiIsInVucmVnaXN0ZXIiOmZhbHNlfQ==',
      gas: 100000000000000,
      deposit: '1'
    }
  }

See on explorer:

{
  "token_id": "snailcoin.snails_fi.testnet",
  "amount": "668369984712",
  "unregister": false
}

Thank you,


Solution

  • it's base64

    using https://www.base64decode.org I see

    {"token_id":"snailcoin.snails_fi.testnet","amount":"668369984712","unregister":false}
    

    for sure you would do this using a library or something, maybe this https://www.npmjs.com/package/js-base64