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

@libertypie/truffle-seeder

v1.1.9

Published

Easily seed initial data to smart contracts using this npm package

Downloads

26

Readme

Truffle Seeder (From Liberty Pie)

Easily seed initial data to smart contracts using this npm package

Installation

via npm

npm i --save @libertypie/truffle-seeder

via yarn

yarn add  @libertypie/truffle-seeder

Usage

Create new seed file

yarn seeder-init --contract HelloContract --method SetHelloMethod

the --contract is the contract you are targeting (eg. HelloContract)
and --method is the method or function in the targeted contract

after the seed files has been created, check the seeds folder in your project root and edit the file in the files sub folder

below is a sample of how a seed file looks like

module.exports = {
    contract: 'HelloContract',
    method:   'SetHelloMethod',
    data: [
        /* 
         * to seed args multiple times, add extra arrays
         ['arg1','arg2',...'argn'],
         ['arg1', 'arg2'...'argn']
        */
    ]
}

You add the args using an array inside the data array as shown

Seed File Options

contract:

The name of the contract you are targeting, it should exist in truffle build folder

method:

The method or function in the targetted contract where the data will be fed to

processor:

The processor is the function responsible for processing the data and calling the method/function from the contract The default processor is located at src/processors/StandardSeedProcessor.js

below is a seed file with a custom processor

module.exports = {
    contract: 'HelloContract',
    method:   'SetHelloMethod',
    processor: customDataProcessor,
    data: [
        /* 
         * to seed args multiple times, add extra arrays
         ['arg1','arg2',...'argn'],
         ['arg1', 'arg2'...'argn']
        */
    ]
}

// customDataProcessor
customDataProcessor = async ({
    contractName,
    contractInstance, 
    contractMethod, 
    argsArray,
    networkId,
    web3,
    web3Account
}) => {
  //process and insert data here 
}

Seeding the data

To seed the data to the contract's method, you will run the command below

 yarn seeder-run 

About

The npm package is developed maintained by the team at LibertyPie Project

Contribution

To contribute, kindly fork the project, at project root create a dev.env file, insert APP_ROOT_DIR pointint to your truffle project where testing will be done, example:

 APP_ROOT_DIR=/path/to/truffle/solidity/project