我研究了文档并审阅了帖子,但无法进行调动。 我没有收到任何错误,但是交易没有执行。我注意到在web3.py文档中,它们只是一种转移方法,而Gemini USD合约使用的是transferFrom方法。传输方法也不起作用。感谢小费。密钥正确,我可以连接到帐户。
!export INFURA_API_KEY="<key>"
from web3.auto.infura import w3
from ethtoken.abi import EIP20_ABI
from eth_account import Account
w3.isConnected()
# private key kunde
acct = w3.eth.account.privateKeyToAccount("<key>")
# wallets
A = "<key>"
contract = "0x056Fd409E1d7A124BD7017459dFEa2F387b6d5Cd"
berheimer = "<key>"
value = 500
assert acct.address == A
unicorns = w3.eth.contract(address=contract, abi=EIP20_ABI)
nonce = w3.eth.getTransactionCount(A)
# Build a transaction that invokes this contract's function
unicorn_txn = unicorns.functions.transferFrom(
A,
B,
value,
).buildTransaction({
'chainId': 1,
'gas': 500000,
'gasPrice': w3.toWei('1', 'gwei'),
'nonce': nonce,
})
print(unicorn_txn)
signed_txn = w3.eth.account.signTransaction(unicorn_txn, private_key=acct.privateKey)
result=w3.eth.sendRawTransaction(signed_txn.rawTransaction)