2

I want to get the token balance of RMRK in the chain statemine with py-substrate.

1 Answer 1

3
from substrateinterface import SubstrateInterface

ASSET_ID = 8  # RMRK.app
ACCOUNT = '<<YOUR_ACCOUNT>>'

substrate = SubstrateInterface(url='wss://statemine-rpc.polkadot.io')
account_info = substrate.query(
    module='Assets',
    storage_function='Account',
    params=[ASSET_ID, ACCOUNT],
)

print(f'Balance: {account_info["balance"]}')
4
  • Is there full doc about how to use substrateinterface?
    – Jack
    Commented Mar 3, 2022 at 3:31
  • Sure, you can always check its repository: github.com/polkascan/py-substrate-interface. It also has a Github page here: polkascan.github.io/py-substrate-interface Commented Mar 3, 2022 at 3:49
  • .Hi, The doc is very simple and can't help me. Can you help me to solve some issues? How to send a rmrk transaction ? I define the: call_module = "Assets" and call_function = 'transfer', call_params = { "id": 8, "target": target, 'amount': amount, }. But when I call "substrate.create_signed_extrinsic", the error "ValueError: Element "asset_id" of struct is missing in given value".
    – Jack
    Commented Mar 4, 2022 at 6:43
  • Without the whole code is hard to get it but maybe do what the error is point out? Like replacing "id": 8 by "asset_id": 8? Commented Mar 4, 2022 at 18:36

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.