question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ricmoocommented, Feb 1, 2021

For this purpose, the UnsignedTransaction and PopulatedTransaction should be compatible.

You could probably use tx = await voidSigner.populateTransaction(tx) to populate the chainId, gasLimit, gasPrice and nonce properties.

Let me know if that works.

1reaction
shinsunycommented, Jan 7, 2021

@ricmoo Thank you so much !! Reply was so quick.

Then I will be using provider.sendTransaction.

Will get back in case of any issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Calling a smart contract function with an unsigned transaction
1. The process has access to Alice's private key so that it can send a signed transaction with the data to the withdraw...
Read more >
Serialization of unsigned or partially signed transactions
The purpose of this format is to send unsigned and partially signed transactions to cosigners or to cold storage. This is achieved by...
Read more >
Generate an Unsigned Transaction and Signing Payloads
It returns an unsigned transaction blob and a collection of payloads that must be signed by particular AccountIdentifiers using a certain SignatureType.
Read more >
Transactions - Ethers.js
An unsigned transaction represents a transaction that has not been signed and its values are flexible as long as they are not ambiguous....
Read more >
What is unsigned transaction? : r/Bitcoin - Reddit
First, transaction is created (as unsigned) - i.e. outputs are set and inputs are chosed from available ouputs of previous transactions and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found