I am trying to send a transaction that updates the state of a smart contract. I have locally deployed a ethereum network using Geth and three VM.

Here is my JS code:

import { Web3 } from 'web3';
import { promises as fs } from 'fs';
const network = "ws://192.168.X.X:8546";

const web3 = new Web3(network);
const wallet = web3.eth.accounts.wallet;
const account = web3.eth.accountProvider.privateKeyToAccount('PRIVATE_KEY');
web3.eth.defaultAccount = account.address;

const abi = JSON.parse(await fs.readFile("contracts/Contract.abi", "utf-8"));
const contract_address = await fs.readFile("contracts/Contract.address", "utf-8");

const contract = new web3.eth.Contract(abi, contract_address);
contract.defaultAccount = account.address;

let registered = await contract.methods.isRegistered(account.address).call();

let response = await contract.methods.registerEV(account.address).send();

I can send money from the account I am trying to send a smart contract transaction from, and also run the first call() method. However, when it tries to run the send() function, I get the following error message:

innerError: { code: -32000, message: 'unknown account' },
  code: 101,
  data: undefined,
  request: {
    jsonrpc: '2.0',
    id: '3d40b26e-d5d8-4c27-8cb3-5293308f7c1c',
    method: 'eth_sendTransaction',
    params: [
        to: '0xbB94D2d82e1464a9Fbb8f150b981a82fB6C8bb8e',
        from: '0x5DAff3F5C181fE4692CAD290d729D8478ee34E1D',
        input: '0x937d117b0000000000000000000000005daff3f5c181fe4692cad290d729d8478ee34e1d',
        gasPrice: '0x3b9aca00',
        maxPriorityFeePerGas: undefined,
        maxFeePerGas: undefined

What can the problem be?

I am running this on Node, using web3js. The account used was created using: web3.eth.accounts.create()

Thanks for any help!

  • Im having the same issue, havent had much luck Nov 3 at 4:09


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.