Git Product home page Git Product logo

eth-connect's Introduction

eth-connect

NPM version codecov Install Size

eth-connect is a TypeScript-based web3 library alternative which implements the Generic JSON RPC spec as well.

You can follow the JavaScript API documentation until TypeScript docs are released.

Design goals

  • A Typed web3.js alternative
  • Have as few convention-invented functions as possible (by following the RPC specs as much as possible)
  • Leverage WS and HTTP providers
  • Portable (support and work equally in both browser and node)
  • Painless eth usage: Using contract factories, well-split event types (block, transaction and contracts plus topics)
  • async/await out of the box

Installation

Using NPM:

npm i eth-connect

Importing as a browser module:

<script src="https://unpkg.com/eth-connect@latest/eth-connect.js"></script>

Examples

Below are some simple illustrative examples. You can also find more complete examples are in the integration /tests folder.

Initialize with a provider

import { RequestManager } from 'eth-connect'

// using the injected MetaMask provider
const requestManager = new RequestManager(web3.currentProvider)

const myBalance = await requestManager.eth_getBalance(myAddress)

or

import { RequestManager, HTTPProvider } from 'eth-connect'

const provider = 'my-own-RPC-url'
const providerInstance = new HTTPProvider(provider)
const requestManager = new RequestManager(providerInstance)

const someBalance = await requestManager.eth_getBalance(someAddress)

Initialize a contract

import { RequestManager, ContractFactory } from 'eth-connect'

const abi = require('./some-contract-abi.json')
// using the injected MetaMask provider
const requestManager = new RequestManager(web3.currentProvider)

const factory = new ContractFactory(requestManager, abi)
const instance = await factory.at(address)

console.log('Calling a method', await instance.mint(myAddress))

Get the accounts

import { RequestManager } from 'eth-connect'

const requestManager = new RequestManager(web3.currentProvider)

const accounts = await requestManager.eth_accounts()

Build the project

Clone this project and run the following in the terminal:

make build

Run tests

make test-local

Comparison

web3 eth-connect
Browser support โœ” โœ”
Promise API โœ– โœ”
Strict type checks โœ– โœ”
TS/JS Docs โœ– โœ”
Wiki Docs โœ” ?
Coverage
Dependents
Install size

Project Status

You can find full documentation here.

You may find issues while using this library, as it's still under development. Please report any issues you come accross.

eth-connect's People

Contributors

belohlavek avatar cruzdanilo avatar dependabot-preview[bot] avatar dependabot[bot] avatar eordano avatar fmiras avatar hugoarregui avatar mcortesi avatar menduz avatar nachomazzara avatar nchamo avatar

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.