Send unsigned transaction
See original GitHub issue@ricmoo Thanks for the awesome work !!!
can be thought of next steps from here: https://github.com/ethers-io/ethers.js/issues/535
I have a contract (object) with voidSigner.
const contract = new ethers.Contract(
addr,
abi,
voidSigner
);
NOTE: signer
is on different system
Basically I want this contract to be called by account whose private key is on different server/system.
So I am using a voidSigner from its public account address.
Making sure that nounce
and other public info could be filled up in order to make a transaction.
So preparing txHash
and getting it signed like this.
// Make Unsigned transaction object
// https://docs.ethers.io/v5/api/contract/contract/#contract-populateTransaction
const unsignedTx = await contract.populateTransaction.create(
a,
b,
c
);
// Serialize the transaction
// https://docs.ethers.io/v5/api/utils/transactions/#utils-serializeTransaction
const serializedUnsignedTx = ethers.utils.serializeTransaction(unsignedTx);
// compute the hash necessary for siging the transaction
const txHash = ethers.utils.keccak256(serializedUnsignedTx);
let txSig;
// txSig = crypto_signer.getSignature(info.getAccountId(), txHash);
So I have all the pieces for a complete transaction:
unsignedTx
txHash
signature
do I need to make Transaction object separately to call provider.sendTransaction( transaction ) or is there any better way to send my transaction.
Thank YOU !!
Another way I could think of is again using ethers.utils.serializeTransaction( tx [ , signature ] ) with signature, and use jsonRpcProvider.send( method , params )
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
For this purpose, the UnsignedTransaction and PopulatedTransaction should be compatible.
You could probably use
tx = await voidSigner.populateTransaction(tx)
to populate thechainId
,gasLimit
,gasPrice
andnonce
properties.Let me know if that works.
@ricmoo Thank you so much !! Reply was so quick.
Then I will be using provider.sendTransaction.
Will get back in case of any issue.