def store_trade(contract_address,
                trade_id,
                buyer=buyer,
                seller=seller,
                seed_phrase=seed_phrase,
                value_to_contract=value_to_contract,
                gas=gas,
                fid=function_ids["store_trade"],
                rate=default_rate):
    '''
	A function to call the dummy ERC20 contract and store a trade. 

    Parameters:
    contract_address (str): address of the deployed contract, 
    	e.g. 5DvtpRYA3hWCwhW3NrrVJCNZinYgSy4W2Sgg38SYkv62LUpQ
	trade_id (str): a number between 00 and 63 representing a trade ID in hex (e.g. 10 = 0a).
	seed_phrase (str): a string of 12 words to restore a Polkadot account. 
	value_to_contract (str): the value sent to the contract within this transaction (0 in this case).
	gas (str): the maximum allowed gas for this transaction. 
	fid (str): the hex representation of the function, generated in the metadata. 

	'''
    buyer_addr = utils.address_to_hex(buyer)
    seller_addr = utils.address_to_hex(seller)
    store_trades = subprocess.run(["polkadot-js-api",
     "--seed",
     "\""+seed_phrase+"\"",
     "tx.contracts.call",
     "{}".format(contract_address),
     value_to_contract,
     gas,
     fid  + "{}".format(trade_id) + "{}".format(buyer_addr) + "{}".format(seller_addr) + \
     "{}".format(value)  + "{}".format(rate) ])
def cmd_watch(args):
    hex_value = address_to_hex(args.address)

    print "Watching", hex_value

    args.api.transact(args.contract_address, funid=3, data=[xint(hex_value)])
    if args.wait:
        args.api.wait_for_next_block(verbose=True)
Beispiel #3
0
def cmd_watch(args):
    hex_value = address_to_hex(args.address)

    print "Watching", hex_value

    args.api.transact(args.contract_address, funid=3, data=[xint(hex_value)])
    if args.wait:
        args.api.wait_for_next_block(verbose=True)
def cmd_getreceivedbyaddress(args):
    hex_value = address_to_hex(args.address)
    record = get_address_record(args.api, args.contract_address,
                                xint(hex_value))
    pprint(record)
Beispiel #5
0
def cmd_getreceivedbyaddress(args):
    hex_value = address_to_hex(args.address)
    record = get_address_record(args.api, args.contract_address, xint(hex_value))
    pprint(record)