G6 Python3 SDK
Last updated
Was this helpful?
Was this helpful?
substrate = SubstrateInterface(
url="wss://gen6.app:443/node",
ss58_format=355,
type_registry_preset='substrate-node-template'
)print("## Chain:", substrate.rpc_request("system_chain", []))
print("## Node name:", substrate.rpc_request("system_name", []))
print("## Node version:", substrate.rpc_request("system_version", []))
rv = substrate.rpc_request("state_getRuntimeVersion", [])
print("## Raw runtimeVersion RPC:", rv)result = substrate.query('System', 'Account', ['g6ACqyvx3otpNgA3GmCP6ugJFfM7NEfq92GSdry32R52r3bJJ'])
print(f"## Testing balance check: { result.value['data']['free']}")keypair = Keypair.create_from_uri('//Alice')call = substrate.compose_call(
call_module='Balances',
call_function='transfer_keep_alive',
call_params={
'dest': recipient_address,
'value': 10000000000
}
)
# Wrap in a signed TX
extrinsic = substrate.create_signed_extrinsic(call=call, keypair=keypair)receipt = substrate.submit_extrinsic(extrinsic, wait_for_inclusion=True)
print("## TX sent!")
print("## TX error:", receipt.error_message)try:
print("## TX is success:", receipt.is_success)
except:
print("## TX failed, check balance!")
exit
print("## TX hash:", receipt.extrinsic_hash)
print("## Block hash:", receipt.block_hash)