New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ethereumjs-connect

Package Overview
Dependencies
Maintainers
1
Versions
287
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethereumjs-connect

Basic Ethereum connection tasks

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-85.71%
Maintainers
1
Weekly downloads
 
Created
Source

ethereumjs-connect

Build Status Coverage Status npm version

ethereumjs-connect handles basic Ethereum network connection tasks: it gets the network ID, selects the right set of contracts for you (by default, it uses the Augur contracts), looks up the coinbase address, etc.

Usage

$ npm install ethereumjs-connect

To use ethereumjs-connect in Node.js, simply require it:

var connector = require("ethereumjs-connect");

A minified, browserified file dist/ethereumjs-connect.min.js is included for use in the browser. Including this file attaches a connector object to window:

<script src="dist/ethereumjs-connect.min.js" type="text/javascript"></script>

ethereumjs-connect can connect to an Ethereum node, which can be either remote (hosted) or local. To specify the connection endpoint, pass your RPC/IPC connection info to connector.connect:

connector.connect("http://localhost:8545");

After connecting, several network properties are attached to the connector object:

connector.network_id
connector.from       // sets "from" for outgoing transactions
connector.coinbase
connector.connection
connector.contracts  // contracts (indexed by network ID)
connector.tx         // ethrpc transaction objects
connector.debug      // turns on debugging logs

connector.from is used to set the from field for outgoing transactions. By default, it is set to the coinbase address. However, if you manually set it to something else (for example, for client-side transactions):

connector.from = "0x05ae1d0ca6206c6168b42efcd1fbe0ed144e821b";
connector.connect("http://localhost:8545");

To connect to a remote Ethereum node, pass its address to connector.connect. For example, to connect to one of Augur's public nodes:

connector.connect("https://eth1.augur.net");

connector.connect also accepts a second argument specifying the path to geth's IPC (inter-process communication) file. IPC creates a persistent connection using a Unix domain socket (named pipe on Windows). This is significantly faster than HTTP RPC, but requires access to the filesystem, so it cannot be used from the browser.

If your Ethereum data directory is ~/.ethereum, then to connect to a local Ethereum node with IPC support:

var ipcpath = require("path").join(process.env.HOME, ".ethereum", "geth.ipc");
connector.connect(null, ipcpath);

If the last argument provided to connector.connect is a function, it will connect asynchronously. This is recommended, especially for in-browser use! For example:

connector.connect("https://eth1.augur.net", function (connected) {
    // fun times
});

Tests

$ mocha

Keywords

FAQs

Package last updated on 02 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc