2

I want to make a function that allows you to send tokens from one owner to another.

    nonce = w3.eth.getTransactionCount(from_['address'])

    unsigned_transaction = contract.functions.transferFrom(
        from['address'],
        to['address'],
        1
    ).buildTransaction({
        'chainId': 1,
        'gas': 70000,
        'gasPrice': w3.toWei('1', 'gwei'),
        'nonce': nonce,
    })

    signed_transaction = sign_transaction(
        unsigned_transaction,
        from['private']
    )

    tx_ref = send_transaction(signed_transaction)

But I get the following error:

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

What am I doing wrong?

Who in this case is the sender? What's wrong with him?

0

It's 'chainId' problem. mainnet is 1, ropsten is 3

0

This error message is directly from Ethereum node, not web3.py:

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

My gut feeling is that from['address'] account is not configured on your Ethereum node - private key not imported. Thus, your Ethereum node cannot sign the transaction and send it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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