First, you need to generate your transaction, here is an example:
let tx_builder = contractInstance.methods.myMethod(arg1, arg2, ...);
let encoded_tx = tx_builder.encodeABI();
let transactionObject = {
gas: amountOfGas,
data: encoded_tx,
from: from_address,
to: contract_address
};
Then you can sign the transaction, using the address and the private key of this specific address. When it is signed, you can send it to the node:
web3g.eth.accounts.signTransaction(transactionObject, private_key, function (error, signedTx) {
if (error) {
console.log(error);
// handle error
} else {
web3g.eth.sendSignedTransaction(signedTx.rawTransaction)
.on('receipt', function (receipt) {
//do something
});
}
Edit: After signing it, you don't have to send it. You can add it to the batch request.
Version 4.x of web3.py requires all addresses use a proper EIP 55 checksum. In my testing, I receive the same error as you until I convert the address to the correct checksummed form (note the capitalization):
0xe980E77404ae62aB0F2d6b8510BD951e25185414
(Note that you also have an extra comma that makes your code syntactically invalid, but I assume that's just a copy/paste error.)
Best Answer
Figured it out: