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

@pigzbe/erc20-contract

v3.3.2

Published

Pigzbe Wollo ERC20 contract

Downloads

8

Readme

Pigzbe ERC20 Burnable Contract

This contract is based on OpenZeppelin.org Burnable Token

https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/token/ERC20/BurnableToken.sol

This tool is intended to be used in any Pigzbe/Wollo project that requires access to the ERC20 Token, so all applications have the same code.

Install on your project

yarn add @pigzbe/erc20-contract

.env.json file

Run on your project folder

pigzbe-contract init

this will create a .env.json file in for you or create an .env.json file in manually with the following

You only need the local network parameters, the tool will output a JSON file with the deployed networks automatically.

{
  "CONTRACT_VARS_PATH": "./erc20-contract.json",
  "networks" : {
    "local" : {
      "KEY_MNEMONIC": "",
      "SEED_INDEX": 0,
      "RPC_HOST": "http://127.0.0.1:7545"
    }
  }
}

Vars description:

  • CONTRACT_VARS_PATH is where the Contract variables will be output
  • CONTRACT_SOL_DIR is where the flattened sol contracts will be output
  • KEY_MNEMONIC Is the Ethereum account memorable works (seed)
  • SEED_INDEX Index account the tool should derive the seed in order to get the private key of the account
  • PRIVATE_KEY is the ethereum private key account to deploy the contract from

Use either KEY_MNEMONIC + SEED_INDEX combination or PRIVATE_KEY to deploy your contracts to the networks

To deploy the contract locally run

if you have exported the local node_modules folder on your bash profile

export PATH="./node_modules/.bin/:$PATH"

You can run the following commands without prefixing it with ./node_modules/.bin


# looks for the default .env.json file in the project root and deploy on default local network
pigzbe-contract deploy

# looks for the default .env.json file in the project root and on all networks listed on .env.json, otherwise only compile/deploy to local network

# BE EXTRA CAREFUL WHEN USING THE FOLLOWING FLAGS, ALL PROJECTS SHOULD BE UPDATED TO GET THE NEW CONTRACTS

# Compiles and deploys new contracts
pigzbe-contract deploy

# Compiles contracts without deploying to any networks
pigzbe-contract deploy --dryrun

# if you want to pass a different path for your .env.json file
pigzbe-contract deploy --env .env.json

# you can check the help by running
pigzbe-contract --help

# or a help for the deploy function  by running
pigzbe-contract deploy --help

This will take the .env.json file, create the wallet to deploy the contract to the network, merge the contract with the latest OpenZeppelin dependencies, create the ABI and Binary of the contract, deploy on local network and create a JSON file in the path set on CONTRACT_VARS_PATH in the .env.json with the following


{
  "TokenName": {
    "abi": [],
    "networks": {
      "local": {
        "network": "local",
        "rpc": "Network RPC",
        "name": "Contract Name",
        "address": "Address the contract is deployed to"
      },
      [...]
    }
  }
}

With those parameters, you can use web3 to create and interact with your contract like


const Web3 = require('web3')
const ercContract = require('../erc20-contract.json')

const getContract = async () => {
  const contract = ercContract.local
  // your local geth server RPC http url
  const URL_PROVIDER = contract.rpc
  const web3 = new Web3(new Web3.providers.HttpProvider(URL_PROVIDER))

  try {
    const deployedContract = new web3.eth.Contract(contract.abi, contract.address, {
      gasPrice: await web3.eth.getGasPrice(),
      gas: 6721975
    })

    console.log(deployedContract)
  } catch (e) {
    console.log(e)
  }
}

getContract()