-
Hi, I've searched on Google and found this answer. This will create a pre EIP-155 tx (without I've found that I can add a const abi = // my ABI here
const contractAddr = '0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0';
const contract = new ethers.Contract(contractAddr, abi)
let transaction = {
nonce: Number(424242),
gasLimit: Number(42),
gasPrice: Number(4242),
// chainId: 1, // Ideally chainId would be specified here but getting 'cannot override "chainId"'
}
let unsignedTx = await contract.populateTransaction.wrap(Number(10000000), transaction);
unsignedTx.chainId = 1; // Is this really how it should be done?
let ser = ethers.utils.serializeTransaction(unsignedTx); So I guess I have two questions:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
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)
Ethers do not have file accessing as it is platform dependent thing. In node js you can simply do: const abi = require('../path/to/abi.json'); // works if json
const content = fs.readFileSync('../path/to/abi.json', 'utf8')
const abi = JSON.parse(content); |
Beta Was this translation helpful? Give feedback.
First you can get a populated transaction and then add the other overrides to it.
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)