I am using python substrate Interface (https://github.com/polkascan/py-substrate-interface) to interact with the substrate node.
I need to execute Pallet::Balances::transfer twice by combine both of my transaction in the utility batch. Now I wanted to retrieve the status and other details of my transaction. How Can I do that. Following is the code that I am using:
from substrateinterface import SubstrateInterface, Keypair
from tools.utils import show_extrinsic, WS_URL, TOKEN_NUM_BASE,transfer
from tools.two_address_substrate_with_extrinsic import show_account
def pallet_utility_test():
substrate = SubstrateInterface (
url=WS_URL
)
kp_src = Keypair.create_from_uri('//Alice')
kp_dst=Keypair.create_from_uri('//Bob')
nonce = substrate.get_account_nonce(kp_src.ss58_address)
amount_to_be_transfered= 10
#first valid transaciton
payload_first = substrate.compose_call(
call_module='Balances',
call_function='transfer',
call_params={
'dest': kp_dst.ss58_address,
'value': amount_to_be_transfered * TOKEN_NUM_BASE
})
#Second invalid transaciton
payload_second = substrate.compose_call(
call_module='Balances',
call_function='force_transfer',
call_params={
'source': kp_src.ss58_address,
'dest': kp_dst.ss58_address,
'value': amount_to_be_transfered * TOKEN_NUM_BASE
})
batch = substrate.compose_call(
call_module='Utility',
call_function='batch',
call_params={
'calls': [payload_first.value, payload_second.value],
})
extrinsic = substrate.create_signed_extrinsic(
call=batch,
keypair= kp_src,
era={'period': 64},
nonce=nonce
)
receipt = substrate.submit_extrinsic(extrinsic, wait_for_inclusion=True)
if not receipt.is_success:
print(substrate.get_events(receipt.block_hash))
raise IOError