casper-ecosystem / cep18

Implementation of ERC20 token for the CasperLabs platform.
https://casper.network/docs/dapp-dev-guide
Apache License 2.0
26 stars 47 forks source link

RPC error Invalid params from transfer deploy #102

Closed piotrwitek closed 1 year ago

piotrwitek commented 1 year ago

Hi, I'm sending a transfer deploy using the JS CEP18Client from here and I got the following error from RPC, could you please clarify what it means as it doesn't tell anything specific.

{
  "jsonrpc": "2.0",
  "id": "0",
  "error": {
    "code": -32602,
    "message": "Invalid params",
    "data": null
  }
}

Here is the deploy generated from the CEP18Client:

{"jsonrpc":"2.0","id":"0","method":"account_put_deploy","params":{"deploy":{"hash":"32c38ee2f2fb611ea02f52603aeed79865097f8adb165a0f169afec1722b7dde","header":{"account":"020304Bb523043dec125E3f31efA82fF2B8E30dF97211bcf87CDb3B6BaE6586AdD4A","timestamp":"2023-06-23T13:54:52.666Z","ttl":"30m","gas_price":1,"body_hash":"b61f918d9f7d788b619da298651b3b82c98fb01dc1574ed6b84d22cae0e37b4f","dependencies":[],"chain_name":"casper-test"},"payment":{"ModuleBytes":{"module_bytes":"","args":[["amount",{"bytes":"0480f0fa02","cl_type":"U512"}]]}},"session":{"StoredContractByHash":{"hash":"","entry_point":"transfer","args":[["recipient",{"bytes":"00f98f2ed4ea79f13cf3e5681e5b2dfbb2b9ef48770a76f04f2f934503522a44f5","cl_type":"Key"}],["amount",{"bytes":"0103","cl_type":"U256"}]]}},"approvals":[{"signer":"020304Bb523043dec125E3f31efA82fF2B8E30dF97211bcf87CDb3B6BaE6586AdD4A","signature":"0222d7ae442bf1cb244aea8536aea3b6b507b2a7f1614a02d0f3d3cbbd36435813651ba04d19f1b8ba4b5c5db481016874027c5a1a97c9911f4c877add5806cb33"}]}}}

Could you please advise what is wrong?

davidatwhiletrue commented 1 year ago

@piotrwitek hash field for the contract hash is empty. Are you calling setContractHash ?

https://github.com/casper-ecosystem/cep18/blob/a3388a9f9fe1131366b6cf57a9d7a7a0ea28e859/client-js/examples/usage.ts#L42

piotrwitek commented 1 year ago

yes I'm calling that, but I'll debug if the values are set correctly before calling the setContractHash

piotrwitek commented 1 year ago

Fixed the issue, it was on my side, thanks @davidatwhiletrue for suggestions on where to look for!