3

我正在尝试调用路由器合约的 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),
    })

我在交易中收到以下错误:

交易截图

4

1 回答 1

2

更新:

上面的代码在增加气体并frombuildTransaction.

于 2021-02-28T21:44:54.133 回答