Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

119
Views
How to add node modules in Geth JavaScript console

I'm using Geth for bloackchain transactions. In the miner console we have some already existing commands. I wanted to create some more functions in a JavaScript file- (functions.js). So I'm using loadScript to load the script. - https://geth.ethereum.org/docs/interface/managing-your-accounts

enter image description here

In the functions.js, I have created some functions like


function printAllETHBalances() {
    for (var acctNum in eth.accounts) {
        ...
    }
    return true;
};

function transferUSD(senderAddress, receiverAddress , amount, password){   
    return personal.sendTransaction({
        from: senderAddress,
        ...
        }, password)
            
};
    

Now I wanted to import and use node modules in the JavaScript functions. Adding import statement in JavaScrript functions file, gives the error.

var http = require('http');   // Error -   Cannot find module 'http'
var fs = require('fs');

enter image description here

How do I add node module, Is there any way to preload the node modules in the Geth Console.

I know this question is already asked - https://ethereum.stackexchange.com/questions/6696/using-node-js-modules-code-from-the-javascript-console-of-geth Thanks in Advance!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!