6

In the contracts tutorial, quite a long piece of code is provided on the geth console to the client:

[...]
function(e, contract){
  if(!e) {

    if(!contract.address) {
      console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined...");

    } else {
      console.log("Contract mined! Address: " + contract.address);
      console.log(contract);
    }

  }
}

How could I provide this function definition from an external file to the console?, such that I don't have to write it all on the console which is quite inconveniente i find.

1 Answer 1

7

The loadScript function in geth takes an external JS file and executes it.

Example usage:

//somefile.js
function foo() {...};

In console:

loadScript('somefile.js');
foo();

It's loaded as if every line was executed directly, like node.js .load

2
  • Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – q9f
    Commented Jun 11, 2016 at 14:52
  • I've added more detail. Commented Jun 11, 2016 at 15:10

Your Answer

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

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