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

trufflepig

v1.1.2

Published

Truffle contract artifact loading tool for local development

Downloads

28

Readme

TrufflePig 🍄🐷

Greenkeeper badge

TrufflePig is a development tool that provides a simple HTTP API to find and read from Truffle-generated contract files, for use during local development.

The pig in action!

Installation

Install globally:

$ yarn global add trufflepig

Or as a devDependency to your truffle project:

$ yarn add trufflepig --dev

Prerequisites

  • A Truffle framework project with built contract json files
  • Some means of making HTTP requests and parsing the JSON results

Usage

Just run

$ trufflepig

from your truffle project and access your contracts under

http://localhost:3030/contracts?name=MyContractName

and looks like this:

{
  "contractName": "MyContractName",
  "abi": {},
  ...
}

The contracts will be queried by the contractName property in the truffle .json output. Once contract files are changed, trufflepig picks it up and serves the changed version of it.

Serving accounts data from ganache or geth / parity

Trufflepig not only helps you to access those delicious truffles but also to easily access the set up addresses in ganache, geth or parity. These will be available under

http://localhost:3030/accounts

and looks like this:

{
  "0x57bb04b8a56c4530ea75ded0a8a0632987d7ec44":"0xd4f10bbe0e132a0d7a7aea3d92e68791f548b67dc5d1dac8ad56edfbc5038ba5",
  "0x241b5d67f21f23d03dec3ffc50504472f265745f":"0xb526e1b11956eb45c3c306a9fef1775b44e22c5e6aec30e103d7d973c6b29189",
  ...
}

Usage with ganache

Start ganache using

$ ganache-cli --acctKeys ganache-accounts.json

This will create a ganache-accounts.json in the directory you run ganache from (preferably your project directory)

Then run trufflepig using

$ trufflepig --ganacheKeyFile ganache-accounts.json

Usage with keystore files

You can run your prefered ethereum development node with some accounts set up. In parity run

$ parity --keys-path YOUR_PREFERRED_KEYPATH

and in geth

$ geth --keystore YOUR_PREFERRED_KEYPATH

to define the directory for accounts to use when starting the node. This directory has to contain one or more keystore files in json format.

Trufflepig can conveniently serve those, too! Just start it with

$ trufflepig --keystoreDir YOUR_PREFERRED_KEYPATH [--keystorePassword KEYSTORE_PASSWORD]

Use the --keystorePassword option to provide a password in case your keyfiles ar encrypted.

API

Command line usage

$ trufflepig --help
Options:
  --help                  Show help [boolean]
  --version               Show version number [boolean]
  -p, --port              Port to serve the contracts from [number] [default: 3030]
  -v, --verbose           Be extra chatty [boolean] [default: false]
  -c, --contractDir       Directory to read contracts from [string] [default: "./build/contracts"]
  -g, --ganacheKeyFile    Ganache accounts file (.json), will serve accounts under /accounts [string]
  -k, --keystoreDir       Directory for keystore files, will serve accounts under /accounts [string]
  -s, --keystorePassword  Password to decrypt keystore files [string]

Programmatic usage

const TrufflePig = require('trufflepig');

const pig = new TrufflePig({
    // These are the defaults
    contractDir: './build/contracts',
    port: 3030,
    verbose: true,
    ganacheKeyFile: '',
    keystoreDir: '',
    keystorePassword: '',
});

pig.start();

That's it! Have a lot of fun truffleing!

License

MIT