2

我正在尝试通过 Pancakeswap 路由器合同执行交换。这是我的代码:

def swapTokens():
amountIn = (w3.toWei(0.00001,'ether')) 
amount1  = contractR.functions.getAmountsOut(amountIn, path).call()
amountOutMin = int(amount1[1] *0.9) 
minAmountPrint = w3.fromWei(amountOutMin, 'ether')
print('Minimum recieved:',minAmountPrint)
swap_TX = contractR.functions.swapExactTokensForTokens(
amountIn,
amountOutMin,
path,
myAccount,
(int(time.time()) + 1000000)
).buildTransaction({
'from': myAccount,
'value': w3.toWei(0.0001,'ether'),
'gas': 550000,
'gasPrice': w3.toWei('5','gwei'),
'nonce': nonce,
})
signed_TX = w3.eth.account.sign_transaction(swap_TX, private_key = privateKey)
tx_token = w3.eth.send_raw_transaction(signed_TX.rawTransaction)
print(w3.toHex(tx_token))
print('Your current balance:',w3.fromWei(w3.eth.get_balance(myAccount), 'ether'), 'BNB')

But transaction fails every time with error "Execution reverted" Reverted transactions hashes: https://bscscan.com/tx/0xc3763879d31b34439e023e3dea2bce80472938b69eb22783c9f97c30d7bd8be9 https://bscscan.com/tx/0xc786257bad753fbb65fde0a94fb9d45ac0e66becd675a5583a0183424ca02e75 https://bscscan.com/tx/0xbc2cc37e42bcd682ca30f74b502bbb0fab9af5df39b1fcb3870e99515a706db4 I'我尝试使用tenderly.co 调试这些,但它似乎没有对错误给出任何解释。

4

0 回答 0