Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support to identify payable methods in an arbitrary contract and add an extra field called "value" to add the amount of ICX to be transferred #478

Open
FidelVe opened this issue Aug 16, 2024 · 0 comments

Comments

@FidelVe
Copy link
Contributor

FidelVe commented Aug 16, 2024

payable methods are those that allow for sending ICX in the transaction being signed, currently the tracker has a functionality to allow calling write methods in arbitrary contracts but doesnt yet support payable methods.

Payable methods can be identified in the ABI (score API) with the payable field, here is an example of how the registerPRep method looks in the score API of the chain contract

curl -X POST --data '{"jsonrpc":"2.0","method":"icx_getScoreApi","params":{"address":"cx0000000000000000000000000000000000000000"},"id":604}' https://lisbon.net.solidwallet.io/api/v3 | jq
 
{
  "jsonrpc": "2.0",
  "result": [
    {
      "inputs": [
        {
          "name": "name",
          "type": "str"
        },
        {
          "name": "email",
          "type": "str"
        },
        {
          "name": "website",
          "type": "str"
        },
        {
          "name": "country",
          "type": "str"
        },
        {
          "name": "city",
          "type": "str"
        },
        {
          "name": "details",
          "type": "str"
        },
        {
          "name": "p2pEndpoint",
          "type": "str"
        },
        {
          "default": null,
          "name": "nodeAddress",
          "type": "Address"
        }
      ],
      "name": "registerPRep",
      "outputs": [],
      "payable": "0x1", # field that identifies the method as payable
      "type": "function"
    },
    ...
  ],
  "id": 604
}

adding support for these methods requires

  • identifying if the method is payable or not
  • if the method is payable add a new field called "value" to allow the user to add the amount of ICX being send
  • convert the value from ICX into loop units and the convert to a hex string
  • correctly adding the value in the JSON RPC payload being sent to the wallet for signage and then sending the transaction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant