我正在尝试呼叫路由器合同的swapExactTokensForTokens,我需要将tokenA交换为tokenB。以下是事务的代码:
router = '0x0000000'
abi = '[{"inputs":[{"internalType":"address","name":"_factory","type":"address"},.... {"stateMutability":"payable","type":"receive"}]'
router_contract = w3.eth.contract(router, abi=abi)
tokenA = '0x000...'
tokenB = '0x000...'
path = [tokenA, tokenB]
txn = router_contract.functions.swapExactTokensForTokens(amount, min_amount, path, personal_wallet, (int(time()) +1000) ).buildTransaction({
'gas': 81000,
'gasPrice': w3.toWei('10', 'gwei'),
'nonce': w3.eth.get_transaction_count(personal_wallet),
})我在事务中得到以下错误:
发布于 2021-03-01 05:44:54
更新:
当增加gas并在buildTransaction中添加from字段时,上面的代码运行良好。
https://stackoverflow.com/questions/66404029
复制相似问题