'value at "/0" is required'
'value at "/0" is required'
Loading saved threads...
seojunchian · External communityPost link
External question — Ethereum Stack Exchange
Author: seojunchian
Original post: https://ethereum.stackexchange.com/questions/156468
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
const {Web3} = require("web3");
require("dotenv").config();
const sPrivateKey = process.env.SENDER_PRIVATE_KEY;
const sPublicKey = process.env.SENDER_PUBLIC_KEY;
const rPublicKey = process.env.RECEIVER_PUBLIC_KEY_KEY;
async function main() {
const web3 = new Web3(
new Web3.providers.HttpProvider(process.env.SEPOLIA_API_KEY)
);
const signer = web3.eth.accounts.privateKeyToAccount(sPrivateKey);
web3.eth.wallet.add(signer);
const estimatedGas = await web3.eth.estimateGas({
from: sPublicKey,
to: rPublicKey,
value: web3.utils.toWei("0.01", "ether"),
});
const tx = {
from: sPublicKey,
to: rPublicKey,
value: web3.utils.toWei("0.01", "ether"),
gas: estimatedGas,
maxPriorityFeePerGas: web3.utils.toWei("3", "gwei"),
maxFeePerGas: web3.utils.toWei("3", "gwei"),
};
const signedTx = web3.eth.signTransaction(tx, signer.privateKey);
console.log(signedTx.rawTransaction);
const receipt = web3.eth.sendSignedTransaction(signedTx.rawTransaction);
console.log(receipt.blockNumber);
}
main().catch((error) => console.log(error));
Quote
Report
seojunchian · External communityPost link
External answer — Ethereum Stack Exchange
Author: seojunchian
Original post: https://ethereum.stackexchange.com/a/156500
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
Find the problem and fixed it.
The part I fixed: Instead of rawTransaction after you write signedTx and put dot it shows you raw but I saw in an example of people doing it they wrote rawTransaction so I did the same but didn't work instead of tried raw and worked.
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External question — Ethereum Stack Exchange Author: seojunchian Source score (net votes, not local likes): 0 Original post: https://ethereum.stackexchange.com/questions/156468 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. const {Web3} = require("web3"); require("dotenv").config(); const sPrivateKey = process.env.SENDER_PRIVATE_KEY; const sPublicKey = process.env.SENDER_PUBLIC_KEY; const rPublicKey = process.env.RECEIVER_PUBLIC_KEY_KEY; async function main() { const web3 = new Web3( new Web3.providers.HttpProvider(process.env.SEPOLIA_API_KEY) ); const signer = web3.eth.accounts.privateKeyToAccount(sPrivateKey); web3.eth.wallet.add(signer); const estimatedGas = await web3.eth.estimateGas({ from: sPublicKey, to: rPublicKey, value: web3.utils.toWei("0.01", "ether"), }); const tx = { from: sPublicKey, to: rPublicKey, value: web3.utils.toWei("0.01", "ether"), gas: estimatedGas, maxPriorityFeePerGas: web3.utils.toWei("3", "gwei"), maxFeePerGas: web3.utils.toWei("3", "gwei"), }; const signedTx = web3.eth.signTransaction(tx, signer.privateKey); console.log(signedTx.rawTransaction); const receipt = web3.eth.sendSignedTransaction(signedTx.rawTransaction); console.log(receipt.blockNumber); } main().catch((error) => console.log(error));
Checking account access…