7

I've first tried sending a transaction with 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)

Giving me the following error: ValueError: {'code': -32000, 'message': 'invalid sender'}


Now, I am trying to interact with a contract - calling methods and giving inputs, but I am unsure how to accomplish this.

TylerH
  • 20,799
  • 66
  • 75
  • 101
LeOverflow
  • 301
  • 1
  • 2
  • 16
  • 1
    It seems that you are trying to access the Ethereum chain instead of the Binance Smartchain: `https://mainnet.infura.io/v3/my-api-key`. As far as I know, you can't access the BSC through the Infura APIs. – marsbear Mar 18 '21 at 15:24
  • Yes thank you @marsbear -- I believe you are correct. I've had to perform my transactions with Nodejs and typescript. I would recommend others to do the same until further support is expanded towards bsc for python. – LeOverflow Mar 18 '21 at 21:47
  • https://ethereum.stackexchange.com/questions/92806/is-it-possible-to-send-transaction-in-binance-smart-chain-using-web3-and-ethereu - maybe this answer from stackexchange helps? there are other urls than infura mentioned – Egirus Ornila Mar 30 '21 at 16:40

0 Answers0