web3.py swapExactTokensForTokens失败的事务

2024-10-02 12:27:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图调用路由器合同的swapExactTokensForTokens,我需要将令牌a交换到令牌B。以下是交易代码:

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),
    })

我在事务中遇到以下错误:

screenshot of the transaction


Tags: pathaddresstypeamountpersonalethtransactionrouter

热门问题