def token_approve_allowance(wallet, args, prompt_passwd=True):
if len(args) != 4:
print("please provide a token symbol, from address, to address, and amount")
return False
token = get_asset_id(wallet, args[0])
approve_from = args[1]
approve_to = args[2]
amount = amount_from_string(token, args[3])
tx, fee, results = token.Approve(wallet, approve_from, approve_to, amount)
if tx is not None and results is not None and len(results) > 0:
if results[0].GetBigInteger() == 1:
print("\n-----------------------------------------------------------")
print("Approve allowance of %s %s from %s to %s" % (string_from_amount(token, amount), token.symbol, approve_from, approve_to))
print("Transfer fee: %s " % (fee.value / Fixed8.D))
print("-------------------------------------------------------------\n")
if prompt_passwd:
passwd = prompt("[Password]> ", is_password=True)
if not wallet.ValidatePassword(passwd):
print("incorrect password")
return
return InvokeContract(wallet, tx, fee)
print("could not transfer tokens")
return False
评论列表
文章目录