web3py ABIFunctionNotFound

web3py ABIFunctionNotFound

我是 web3 开发的新手,尝试通过 web3py 签署交易,当我尝试通过 contract.functions.transfer() 功能为 BSC 网络上的 USDC 代币创建转账时出现异常 ABIFunctionNotFound。

web3.exceptions.ABIFunctionNotFound: ("The function 'transfer' was not found in this contract's abi. ", 'Are you sure you provided the correct contract abi?')

令牌 ABI

[{"inputs":[{"internalType":"address","name":"logic","type":"address"},{"internalType":"address","name":"admin","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAdmin","type":"address"}],"name":"changeAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]

如果此联系人没有转账功能,如何将USDC转账到其他钱包?

正如我在评论中猜测的那样,您正在传递 proxy contract 的 ABI。

解决方案很简单:传递 implementation contract 的 ABI(您可以在 BSCScan 上的代理合约中看到它的链接)但保留代理地址。

如果您下次遇到此问题,此规则适用于所有其他代理合同。始终传递代理地址和实现 ABI。