0

What I am trying to do is I am trying to send transactions with web3js. At first I used sign transaction then send signed transaction get the same error after a little bit of research and tryed them. Wouldn't find anything useful finally came here to ask what to do, what is the process of sending transactions and one of the things I get across because of I use public node I cant use the methods it doesnt support. I totaly get that but dont understand why. So first thing is where to find a node that supports the things I ll do or how can I achieve what I want to achieve down there.

const {Web3} = require("web3");
require("dotenv").config();
const contractBuild = require("./build/contracts/Logitech.json");

async function main() {
  const web3 = new Web3(process.env.SEPOLIA_API_KEY);
  web3.eth.wallet.add(process.env.SENDER_PRIVATE_KEY);
  const contract = new web3.eth.Contract(
    contractBuild.abi,
    contractBuild.networks[11155111].address
  );
  const transaction = await contract.methods
    .transfer(process.env.RECEIVER_PUBLIC_KEY, 123)
    .send({from: process.env.SENDER_PUBLIC_KEY});
  console.log(transaction.transactionHash);
}

main().catch((error) => console.log(error));
2
  • Without saying the contents, what is the structure of SEPOLIA_API_KEY? Just about any RPC provider will support sending transaction, so I suspect you aren't properly providing an rpc url
    – natewelch_
    Nov 13 at 20:00
  • yea I wasnt handled it after I asked a question. anyway solved it thx anyway Nov 14 at 13:53

0

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.

Browse other questions tagged or ask your own question.