1

maybe a silly question... Is possible to query a balance using a HTTP call like eth_getBalance? I need a raw http call, like one that i can perform with curl.

I looked the methods that polkadot RPC API expose but none of them query the balance. Also i already know that we have polkadot-js but i need to make a normal HTTP call as I said before.

Thanks guys!

1 Answer 1

3

Here is a simple example of getting Polkadot's total issuance:

curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "state_getStorage", "params": ["0xc2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80"]}' https://polkadot-rpc.dwellir.com
{"jsonrpc":"2.0","result":"0x3a39574d0bd4e0a40000000000000000","id":1}

There is actually a detailed tutorial on this:

Keep in mind that in the tutorial Shawn is querying the storage for the balances pallet. In Polkadot, account balance is stored in the system pallet. You can get the user's account balance via system > account but what you will get back in your response is the SCALE encoded version of a data structure that looks something like this:

{
  nonce: 26
  consumers: 3
  providers: 1
  sufficients: 0
  data: {
    free: 12,082,294,213,399
    reserved: 0
    miscFrozen: 11,099,882,066,510
    feeFrozen: 11,099,882,066,510
  }
}

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.