Code Monkey home page Code Monkey logo

web3-fusion-extend's Introduction

Fusion JavaScript API

A version of the readme as online documentation can be found at:

https://fusionapi.readthedocs.io

This package extends the Ethereum compatible JavaScript API which implements the Generic JSON RPC spec to support the Fusion protocol.

It's available on npm as a node module.

NPM version sudo port select --set python python36

You need to run a local Ethereum node to use this library.

Documentation

Table of Contents

Installation

Node.js

npm install web3-fusion-extend

Yarn

yarn add web3-fusion-extend

Usage

Create a web3 object as your normally would and then call web3FusionExtend with that object. web3 will then have two additional interfaces (fsn and fsntx)

    var web3FusionExtend = require('web3-fusion-extend')
    web3 = new Web3(provider);
    web3 = web3FusionExtend.extend(web3)
    console.log(web3.fsn.consts.FSNToken);
console.log(web3); // {fsn: .., fsntx: ...} // It's here!

There you go, now you can use it:

var balance = web3.eth.getBalance(coinbase);
   web3.fsn
        .getAllBalances( web3.eth.coinbase ) // fsn supports multiple assets and balances on an address
        .then( balances => {
          console.log( balances )
          assert(  balances[web3.fsn.consts.FSNToken] , "there should be a balance for fusion tokens always"  )
          done();
        })
        .catch(err => {
          done(err);
        });

You can find more examples in the test directory.

There is also a full block explorer api written as an example.

Contribute!

We'd greatly appreciate any contribution you make.

Documentation

Documentation

Requirements

  • Node.js
  • npm
# On Linux:
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
sudo apt-get install nodejs-legacy

Testing (mocha)

When testing a connect string to a local fusion node and a wallet address is needed as environment variables

CONNECT_STRING="ws://3.16.110.25:9001" WALLET_ADDRESS="0x4A5a7Aa4130e407d3708dE56db9000F059200C62" npm test

Community

License

LGPL-3.0+ © 2015 Contributors

web3-fusion-extend's People

Contributors

arkivix avatar bret-fusion avatar joeykhd avatar khaneight avatar storuky avatar

Forkers

da-fi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.