akasha:meteor-geth

ethereum geth for meteor dapps


License
MPL-2.0
Install
meteor add akasha:meteor-geth@=0.0.6

Documentation

This package is for ethereum dapp development

What does this package:

  • Exports a global class named GethConnector available only on server
  • Downloads geth binaries
  • Can start geth process
  • Can connect to an ipc geth process and send json-rpc call

Example

  • On server side create a global variable just before Meteor.startup:
  • // for global access on server side
    gethObj = false;
    
    const testGeth = function () {
      // start geth process
      let started = gethObj.start();
      // waits for process to start (Future fiber)
      if (started) {
        // test ipc calls https://github.com/ethereum/go-ethereum/wiki/Go-ethereum-management-API's
        gethObj.ipcCall('personal_listAccounts', [], (err, data)=> {
          console.log('account list ' + data);
        });
      }
    };
    
    Meteor.startup(function () {
      gethObj = GethConnector.getInstance(); // grab singleton instance anywhere
      gethObj.setLogLevel('warn'); // info is default
      testGeth();
    });
  • Then you can use anywhere on server side these methods:

    gethObj.start(); // logs in .meteor/local/log/gethProcess.log
    gethObj.stop();//stop geth process
    gethObj.setOptions({executable:'/usr/bin/geth', dataDir:'.ethereum/datadir', privateNet:true, testNet:false,
      extraOptions: ['--shh', '--rpc', '--rpccorsdomain', 'localhost']})
    gethObj.setLogLevel('info');//info is default; 'trace', 'fine', 'debug', 'info', 'warn', 'error'
    gethObj.ipcCall(name, params, callback));//send json-rpc request, you can find all available methods here https://github.com/ethereum/wiki/wiki/JSON-RPC#json-rpc-methods 
  • Test this package:

    VELOCITY_TEST_PACKAGES=1 meteor test-packages --driver-package velocity:console-reporter akasha:meteor-geth