Skip to content

Correctly creating UnsignedTransaction #1885

Answered by zemse
pscott asked this question in Q&A
Discussion options

You must be logged in to vote

How can I make this cleaner, and put the chainId in the transaction object?

First you can get a populated transaction and then add the other overrides to it.

const {data} = await contract.populateTransaction.wrap(Number(10000000));
let unsignedTx = {
    data,
    nonce: Number(424242),
    gasLimit: Number(42),
    gasPrice: Number(4242),
    chainId: 1
}

Ethers won't allow you to inject a chainId override because chainId is implicit from the provider you're using. In your use case, you have to set the chain id at the last (just before passing the unsignedTx to ledger signer)

Is there a proper way to load the ABI from a file? Ideally I'd have something like const abi = ethers.abi.from…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@pscott
Comment options

Answer selected by zemse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants