3

Binance Smart Chain. 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.

2 Answers 2

2

Infura does not support 56 nor 97 chain ids. These are for BSC, infura only supports Ethereum I suggest using Binance official node url for BSC Mainnet (56): https://bsc-dataseed.binance.org/ Or chainId 97 BSC Testnet: https://data-seed-prebsc-1-s1.binance.org:8545/

1
  • You have working python code with Binance Node?
    – LeOverflow
    Commented May 17, 2021 at 9:34
0

ok so I'm not a programmer and don't really know what im talking about but I don't think you can use infura to call the BSC net. I think infura is for use with etherium. Check this link for the mainnet url for BSC.

https://docs.fortmatic.com/web3-integration/binance-smart-chain

1
  • Hi and welcome, indeed currently Infura doesn't support Eth, one can use binance chain api: bsc-dataseed.binance.org , but the current support for Python is in the air.
    – LeOverflow
    Commented May 8, 2021 at 9:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.