Gas Price null #56
-
I'm getting a The gas price field shows null in the terminal, but is set to a number in transaction data fields
The transaction appears on ganache as a contract creation, however the wallet balances are unchanged
The full error message reads:
full code: const ethers = require("ethers");
const fs = require("fs-extra");
async function main() {
const provider = new ethers.providers.JsonRpcProvider(
"http://127.0.0.1:8545"
);
const wallet = new ethers.Wallet(
"0x5b3208286264f409e1873e3709d3138acf47f6cc733e74a6b47a040b50472fd8",
provider
);
const abi = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.abi", "utf8");
const binary = fs.readFileSync(
"./SimpleStorage_sol_SimpleStorage.bin",
"utf8"
);
const nonce = await wallet.getTransactionCount();
console.log("Let's deploy with only transaction data!");
const tx = {
nonce: nonce,
gasLimit: 30000000,
gasPrice: 2000000000,
to: null,
value: 0,
data: "0x608060..."
chainId: 1337,
};
const sentTxResponse = await wallet.sendTransaction(tx);
await sentTxResponse.wait(1);
console.log(sentTxResponse);
}
main();
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
}); |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
For javascript and solidity code, please add
Thank you! For your issue, could you try a higher gas price? |
Beta Was this translation helpful? Give feedback.
-
Ok, so your values here: gasLimit: 30000000,
gasPrice: 2000000000, Are way off. Could you try: gasLimit: 1000000,
gasPrice: 100000000000, You're also calling main();
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
}); Could you please try copy pasting from the github repo associated with the course? It looks like you have a number of random issues going on. |
Beta Was this translation helpful? Give feedback.
From #56 (reply in thread)
Ok, so your values here:
Are way off. Could you try:
You're also calling
main
twice:Could you please try copy pasting from the github repo associated with the course? It looks like you have a number of random issues going on.