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.

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

  • 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. – Waqar Lim Jun 11 '16 at 14:52
  • I've added more detail. – Matthew Schmidt Jun 11 '16 at 15:10

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.