/ethereum_api

JavaScript RESTFul API for interacting with Ethereum smart contract and blockchain

Primary LanguageJavaScript

Ethereum Blockchain and Smart Contract Interaction API

This module provides an API for an Ethereum node by using web3. web3 documentation can be found here: web3 documentation

Install

Clone the repo and then install dependencies:

$ npm install

The install process creates a new config.js file in the root directory, based on the config.js.default file. There you can set up the parameters for running your instance including the path (in the project root folder) of the full smart contract .json file gotten from truffle deploy --network <network name> which includes the smart contract abi e.g., var/contracts/MetaCoin.json

HTTP RESTful API

In order to start the HTTP API service you just need to run:

$ npm start

or

$ node api

You'll see a message indicating that the service is already running.

Endpoints

  • GET /node/status

    Get the list of accounts in connected blockchain client

  • GET /node/address/:address/balance

    Get the ether balance of an account in wei

  • GET /node/tx/:txhash

    Get the details of a transaction hash

  • GET /node/tx/receipt/:txhash

    Get the full receipt of a transaction

  • POST /node/tx/

    Send ether (wei) from one account to another address or send trnasaction signed offline

  • GET /node/contract/:name/:address/call/:method

    Make a call to a smart contracts view function that does not require gas or transaction signing

  • POST /node/contract/:name/:address/transact/:method

    Make a call to a smart contracts SEND function that requires gas and transaction signing as it changes the state of the blockchain

  • GET /node/gasLimit

    Get the gas limit used in the last mined/approved block

  • GET /node/latestBlock

    Get the details of the latest mined/approved block

  • GET /node/block/:blockNumber

    Get the details of a specified mined/approved block with the block number

  • GET /node/event/:contractName/:address/:fromBlock

    Get all past events from a specified smart contract