def send_token_from_contract_in_bsc(tx_amount, tx_bsc_addr):
    web3_BSC = Web3(Web3.HTTPProvider(bscTestnet_url))
    contract_bsc_addr = web3_BSC.toChecksumAddress('0x74d4c3f8620c69C68a2144D4e1B4B7EE660cBA4D')
    bep20_addr_USDC = web3_BSC.toChecksumAddress('0x64544969ed7ebf5f083679233325356ebe738930')
    contract_bsc = web3_BSC.eth.contract(address = contract_bsc_addr, abi = contractAbi)
    bsc_Nonce = web3_BSC.eth.getTransactionCount(bscAccount)
    contract_method_transferToken = contract_bsc.functions.transferToken(bep20_addr_USDC, web3_BSC.toWei(tx_amount, 'wei'), web3_BSC.toChecksumAddress(tx_bsc_addr))
    contract_method_transferToken_build_tx = contract_method_transferToken.buildTransaction({
      'chainId': 97,
      'nonce': bsc_Nonce,
      'from': web3_BSC.toChecksumAddress(bscAccount),
      'value': web3_BSC.toWei(tx_amount, 'wei'),
      'gas': 21000,
      'gasPrice': web3_BSC.toWei('33', 'gwei'),
    bsc_sign_tx_transferToken = web3_BSC.eth.account.signTransaction(contract_method_transferToken_build_tx, private_key = PRIVATE_KEY)
    bscTxHash = web3_BSC.eth.sendRawTransaction(bsc_sign_tx_transferToken.rawTransaction)

Hello guys! I try to send BEP20 tokens in BSC, All the work fine, tx is subscribes, but doesnt pushed in Testnet, problem come in last line:

bscTxHash = web3_BSC.eth.sendRawTransaction(bsc_sign_tx_transferToken.rawTransaction)

Error: ValueError: {'code': -32000, 'message': 'invalid sender'}

If somebody have idea, I will be glad to see :)

1 Answer 1


I solved my problem, problem was in bscTestnet_url wrong node url.

  • 1
    could you post your correct code here? thanks!
    – Oliver
    Commented Sep 6, 2021 at 23:58

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.