python 无法使用web3发送事务

mcdcgff0  于 2023-02-28  发布在  Python
关注(0)|答案(1)|浏览(155)

我正尝试使用此代码通过fantom网络发送交易。此代码适用于多边形网络,但由于某种原因,它不适用于fantom网络。此令牌合约具有transfer和transferFrom,但它们都不适用于我的代码。
令牌合约:www.example.comhttps://ftmscan.com/address/0x667afbb7d558c3dfd20fabd295d31221dab9dbc2#code

def sendToken(_from, _to, _balance, _from_privet):
transaction = contract.functions.transferFrom(_from,str(_to), w3.toWei(_balance, 'ether')) \
    .buildTransaction({'chainId': 250,
                       'gas': 585901,
                       'nonce': w3.eth.getTransactionCount(_from)})
signed_txn = w3.eth.account.signTransaction(transaction, private_key=_from_privet)
try:
    tx_hash = w3.eth.sendRawTransaction(signed_txn.rawTransaction)
    recipt_hash = w3.eth.wait_for_transaction_receipt(binascii.hexlify(tx_hash).decode())
    print(binascii.hexlify(tx_hash).decode())

但由于某种原因,事务失败,我不明白为什么。此事务有哈希值。0x9a87a2db4776dab986f18cd0e7f832ecdcaa48793be740c79c0f0b1a128f28b5

o7jaxewo

o7jaxewo1#

https://dashboard.tenderly.co/tx/fantom/0x9a87a2db4776dab986f18cd0e7f832ecdcaa48793be740c79c0f0b1a128f28b5
来自日本标准溶液
--剪断

function _transfer(address sender, address recipient, uint256 amount) private {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");
        require(amount > 0, "Transfer amount must be greater than zero");
        if(sender != owner() && recipient != owner())
          require(amount <= _maxTxAmount, "Transfer amount exceeds the 
    maxTxAmount.");

--剪断
发件人似乎不是所有者。

相关问题