如何使用 Python 与币安智能链合约交互

时间:2021-02-28 11:08:13

标签: transactions web3 binance web3py

我第一次尝试用 python 发送交易:

from web3 import Web3

transaction = {
        'chainId': 97,  # 97: Testnet. 56: main.
        'to': '0xmyaddress',
        'value': 1,
        'gas': 2000000,
        'gasPrice': 13,
        'nonce': 0,
    }

infura_url = "https://mainnet.infura.io/v3/my-api-key"
w3 = Web3(Web3.HTTPProvider(infura_url))

key = '0xmykey'
signed = w3.eth.account.signTransaction(transaction, key)

w3.eth.sendRawTransaction(signed.rawTransaction)

给我以下错误:ValueError: {'code': -32000, 'message': 'invalid sender'}


现在,我正在尝试与合同进行交互 - 调用方法并提供输入,但我不确定如何完成此操作。

0 个答案:

没有答案