1

The docs state that the RPC comes with a few defaultRPCs and then links to polkadotJS documentation on the available API calls. This doesn't help me if I want to call a method using curl.

Does anyone know how to call contractInfoOf using curl?

I've tried storage_contract_info_of, storage_contractInfoOf, and various other combinations using contracts as the prefix.

e.g.

curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "contracts_contractInfoOf", ["5CYKEXWU3L4zWregopd2bTjoZLH9yHBpfXaqkFaTfxacaSA1"]}' http://substrate-node:9933/

However, none of these seem valid. I've used grep to look for a list of rpc calls in substrate and I got the following:

> grep -rPo '#\[rpc\(name\s=\s"([A-Za-z_]*)' | sort | uniq | awk -F '"' '{print $2}'
babe_epochAuthorship
engine_createBlock
engine_finalizeBlock
grandpa_proveFinality
grandpa_roundState
author_hasKey
author_hasSessionKeys
author_insertKey
author_pendingExtrinsics
author_removeExtrinsic
author_rotateKeys
author_submitExtrinsic
chain_getBlock
chain_getBlockHash
chain_getFinalizedHead
chain_getHeader
childstate_getKeys
childstate_getKeysPaged
childstate_getStorage
childstate_getStorageEntries
childstate_getStorageHash
childstate_getStorageSize
state_getChildReadProof
offchain_localStorageGet
offchain_localStorageSet
state_call
state_getKeys
state_getKeysPaged
state_getMetadata
state_getPairs
state_getReadProof
state_getRuntimeVersion
state_getStorage
state_getStorageHash
state_getStorageSize
state_queryStorage
state_queryStorageAt
state_traceBlock
system_addLogFilter
system_addReservedPeer
system_chain
system_chainType
system_health
system_localListenAddresses
system_localPeerId
system_name
system_nodeRoles
system_peers
system_properties
system_removeReservedPeer
system_reservedPeers
system_resetLogFilter
system_syncState
system_unstable_networkState
system_version
sync_state_genSyncSpec
contracts_call
contracts_getStorage
contracts_instantiate
contracts_upload_code
mmr_generateProof
payment_queryFeeDetails
payment_queryInfo
system_accountNextIndex
system_dryRun

No mention of contractInfoOf. Where is it located and how do I call it?

4
  • 1
    curl rpc_methods will show you all calls exposed by the node. contractInfoOf is a state call, e.g. the correct storage key to stage_getStorage
    – Jaco
    Commented May 10, 2022 at 18:25
  • Thanks, Jaco. Very helpful.
    – forgetso
    Commented May 10, 2022 at 18:32
  • Is the storage key the encoded contract address? e.g. u8aToHex(decodeAddress("5CYKEXWU3L4zWregopd2bTjoZLH9yHBpfXaqkFaTfxacaSA1"))
    – forgetso
    Commented May 10, 2022 at 19:07
  • 2
    It is encoded using the hasher for the map. One of the examples that show the key I can think of is the apps UI chain-state app, e.g. Canvas on Rococo has contracts, so if you navigate in that app to contracts.contractInfoOf you can see how the key is generated in the details below.
    – Jaco
    Commented May 11, 2022 at 9:56

1 Answer 1

1

I'm reposting the answer from Jaco above, so that this question no longer shows up as one without answers.

curl rpc_methods will show you all calls exposed by the node. contractInfoOf is a state call, e.g. the correct storage key to state_getStorage

Your Answer

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

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