const {Web3} = require("web3");

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);
  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);
  const receipt = web3.eth.sendSignedTransaction(signedTx.rawTransaction);
main().catch((error) => console.log(error));
  • 1
    You did not write where exactly you are getting this error. I can assume that it is sPrivateKey. Is it right? Nov 15 at 5:17
  • Fixed it thanks anyway Nov 15 at 11:29

1 Answer 1


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.

  • Welcome to the Ethereum Stack Exchange! Suggest you write down the problem and fix, so that it can help others?
    – eth
    Nov 15 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.