npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

meterify

v1.4.8

Published

A web3 adaptor for Meter RESTful HTTP API.

Downloads

32

Readme

Meterify   

A web3 adaptor for Meter [Meter] RESTful API.

⚠ WARNING: Specific version of web3.js required.
This implementation is supposed to work with web3.js version lower than v1.2.4. Please be aware it does NOT work well with web3.js v1.3.0, there are some known issues that we are still figuring out.

Table of contents

Install

npm install --save meterify
npm install --save web3@1.*   # Web3 is needed as dependency.

Usage

// ES6 style
import { meterify } from "meterify";
const Web3 = require("web3"); // Recommend using require() instead of import here

const web3 = meterify(new Web3(), "http://localhost:8669");

web3.eth.getBlock("latest").then(res => console.log(res));
// Best block info will be displayed

If you would like to write code in ES5, check below for the initialization code.

// ES5 style
const meterify = require("meterify").meterify;
const Web3 = require("web3");

const web3 = meterify(new Web3(), "http://localhost:8669");

web3.eth.getBlock("latest").then(res => console.log(res));
// Best block info will be displayed

Web3 method supported

web3 instance
├── eth
│   ├── getBlockNumber
│   ├── getBalance
│   ├── getStorageAt
│   ├── getCode
│   ├── getBlock
│   ├── getTransaction
│   ├── getTransactionReceipt
│   ├── sendTransaction
│   ├── sendSignedTransaction
│   ├── call
│   ├── estimateGas
│   ├── getPastLogs
│   ├── subscribe
│   ├── clearSubscriptions
│   ├── getEnergy
│   ├── getChainTag
│   ├── getBlockRef
│   ├── accounts
│   └── Contract
│       ├── Constructor(new Contract())
│       ├── clone
│       ├── deploy
│       ├── methods
│       ├── methods.myMethod.call
│       ├── methods.myMethod.send
│       ├── methods.myMethod.estimateGas
│       ├── methods.myMethod.encodeABI
│       ├── events
│       ├── once
│       ├── events.myEvent
│       ├── events.allEvents
│       └── getPastEvents
└── utils

Send Transaction

In Meter official implementation , the client DOES NOT neither manage user's private-key/keyStore nor use private key to sign a Transaction. Unfortunately, meterify can not directly perform eth_sendTransaction but there is another way to sign a transaction.

In web3.js accounts, it gives the opportunity to add your private-key, stored in your runtime context (In Node.js context, it's stored in memory while in Browser context, it's stored in memory/local storage), to accounts module. When you are trying to send a transaction, the module will check the private key associated with from field. Once the private key and from have been matched, the module will sign the transaction. The APIs that follows the mechanism are:

  • web3.eth.sendTransaction()
  • contract.deploy.send()
  • contract.methods.myMethod.send()

Documentation

Play with multi-clause

  1. @meterio/devkit supports multi-clause and sign transaction

Which Stack Should I Choose Regarding Connex,Meterify And Web3-Gear

  • Connex: The standard interface to connect Dapps with Meter blockchain and user.

If you are writing some application or scripts executing in Node.js or Browser environment, you should use Meterify.

Here are some most common scenarios:

  1. Develop a web application(Recommend): Connex + Connex powered Meter wallets
  2. Backend service in Node.js: Meterify + Web3
  3. Contract development in Truffle: Web3 + Web3-Gear
  4. Contract development in Remix-IDE: Web3 + Web3-Gear

FAQ

Method not supported

The RESTful API of Meter is different with Ethereum's JSON-RPC, therefore, there are some methods in web3 are not supported by meterify, feel free to open an issue discuss the features.

There is a possibility that when you trying to call sendTransaction or send functions, meterify will return Method not supported under version 0.3.1, due to account module will check the private key associated with from field. After upgrade to version 0.3.1 or newer, meterify will show The private key corresponding to from filed can't be found in local eth.accounts.wallet to make an error more specific.

Notes

  • There are three special block number in Ethereum: earliest,latest,pending. In Meter, we introduced best block and there is no pending block, so they will be replaced with 0 (aka genesis), best, best

Compatibility

Currently, meterify is compatible with web3@1.*.

Debugging

DEBUG=meter:* ts-node index.ts

ts-node index.ts can be replaced with command to run your code, this example is only for Node.js environment. For more detailed info, please refer to debug.

License

In addition to the code created by Meter Foundation, this code base contains code from various open source projects. It is currently provided for limited deomonstration and testing only. The license term will be updated after the final review at the the time of the official release. In addition to the code created by Meter Foundation, this code base contains code from various open source projects. It is currently provided for limited demonstration and testing only. The license term will be updated after the final review at the time of the official release.