I have to create a multisignature transaction which the transaction should get signed with at least 2 private keys. Could anyone explain how to do it? I am using web3.py
import rlp
from ethereum.transactions import Transaction
tx = Transaction(
nonce=web3.eth.getTransactionCount(web3.eth.coinbase),
gasprice=web3.eth.gasPrice,
startgas=100000,
to='0xd3cda913deb6f67967b99d67acdfa1712c293601',
value=12345,
data=b'',
)
tx.sign(the_private_key_for_the_from_account)
raw_tx = rlp.encode(tx)
raw_tx_hex = web3.toHex(raw_tx)
web3.eth.sendRawTransaction(raw_tx_hex)
In the above code, I am only signing with one private key. Could anyone explain how to sign with multiple private keys?
Best Answer
An Ethereum transaction should have only one signature, representing the account that will pay the gas for it. If you want to control a resource with multiple signatures, you have two options:
msg.sender
) like you would with a simple transaction, sign the data to the transaction and have your contract check it usingecrecover
. This allows you to collect the signatures out-of-band and submit all the signature data in a single transaction. See this contract for an example.