I'm using loadScript in ethereum console to load a external js file:


// teste.js

function fx() {
return 12;

However when I run it in ethereum console it always returns false: (teste.js is located in a folder 'src' in the datadir - admin.datadir)


Why I do have this behaviour? Should return 12?
I also tried placing the .js in various reasonable locations, but the ouput of loadScript() is always false...

I hope someone could help.



The return value false means that your file in that relative path cannot be found. First try running the file from within the same folder from which you started your geth.

Be reminded that this function will not print the return value to the console like that, you need some console.log. You could write an output with the following file that you store as test.js:

console.log('Hello world');
console.log('You have ' + web3.eth.accounts.length + ' accounts here.');

and then run it from within the geth console via loadScript('test.js'):

> loadScript('parse.js')
Hello world
You have 1 accounts here.
  • Then please mark the answer as accepted. – SCBuergel Aug 29 '17 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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