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

@meterio/contract-toolkit

v0.0.6

Published

Toolkit for contract debugging on meter

Downloads

8

Readme

Contract Toolkit

This is a toolkit library for contract debugging

Prerequisite

You need to create providers.json.

A typical providers.json looks like this, where key is provider-name and value is rpc url config. provider-name is defined in src/const/network.js:

{
  "mainnet": { "url": "http://rpc.meter.io", "meterifyUrl": "http://mainnet.meter.io" },
  "testnet": { "url": "http://rpctest.meter.io", "meterifyUrl": "http://testnet.meter.io" },

  "ethereum": { "url": "https://speedy-nodes-nyc.moralis.io/[key]/eth/mainnet" },
  "bsctest": { "url": "https://data-seed-prebsc-1-s1.binance.org:8545/" },

  "localhost": { "url": "http://localhost:8545", "meterifyUrl": "http://localhost:8669"},
}

Put these providers.json file under safe folders, such as /Users/simon/safe/. And configure .env with

PROVIDERS_CONFIG=/Users/simon/safe/providers.json

And then, please put your private key in keystore and name it with name.keystore pattern, put them under safe folders, such as /Users/simon/keys, And add one more line in .env file

ACCOUNTS_DIR=/Users/simon/keys

Please notice that system will recursively find the keystore file and every time you load the private key, you'll need to type in the passphrase you set when you create the keystore.

Read Usage (call)

Calling a contract is as simple as the following, notice that you could easily load the account you just set in accounts.json by loadAccount. Here's an example calling balanceOf on ERC20.

const { loadAccount, loadWeb3Contract, Network } = require('../const');
const { inst } = loadWeb3Contract(Network.metermain, 'ERC20', 'VOLT_AIR');
(async () => {
  const userAcct = await loadAccount('bob');
  const owner = userAcct.addr;

  const r = await inst.methods.balanceOf(owner).call({});
  console.log(r);
})();

Write Usage (send)

send is a little bit more complex then call, but it's still pretty straightforward. Here's an example calling approve on ERC20.

const { enableAccount, loadAddress, loadWeb3Contract, Network } = require('../const');
const { utils } = require('ethers');

const network = Network.metermain;
const { web3, inst } = loadWeb3Contract(network, 'ERC20', 'VOLT_AIR');

const spender = loadAddress(network, 'Geyser_MTRG_USDC_LP');
const amount = utils.parseUnits('100', 18).toHexString();

(async () => {
  const ownerAcct = await enableAccount(web3, 'bob');
  const r = await inst.methods.approve(spender, amount).send({ from: ownerAcct.addr, gasLimit: 4700000 });
  console.log(r);
})();