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

tartufo

v1.1.6

Published

automatically compiling and deploying solidity in one shot!

Downloads

9

Readme

tartufo

Do you want to help improve this module? Open an issue! Thanks!


    const web3 = await connect("ws://localhost:7545");

    const [ pathFolder, pathContract ] = [ 'contracts/', 'Example.sol'];

    const myContract = await compileDeploy(web3, pathFolder, pathContract, [], 6000000, 1);

    //that's it! Now you can call all your methods!
    myContract.methods.myMethod(123).call({ /* ... */};

With tartufo you can forget about compiling, migrating, ... You just need to specify the main contract and the folder containing all the others smart contracts required from the main one.

That's right, tartufo will automatically find all the dependencies!

No more intermediate products, from *.sol directly to myContract of web3!!

Installation

Tartufo is built upon two main npm modules:

solc 0.4.24+

web3 1.0.0-beta.34+

If you are on Windows you must have a toolchain for compiling C++.

I highly recommend using this great module that will do everything automatically:

windows-build-tools

Finally simply install tartufo.

$ npm install tartufo --save

Please refer to this guide for web3 since I'm using the latest version: web3 1.0

API

Every function is a promise so it must be awaited.

const { connect, compile, createContract, deploy, compileDeploy } = require("tartufo");


//socket can be WebSocket, HTTP or IPC
const web3 = await connect(socket);

//pathContract is the path of the main contract, it must be with the first letter uppercase.
//the folder containing the path must have all the *.sol imported from the main.
//output is an object representing the compiled source
const output = await compile(pathContract);

//web3 is valid instance, the one returned from the method connect(socket)
//jsonInterface is taken from: JSON.parse(output.contracts[keyContract].interface)
const smartContract = await createContract(web3, jsonInterface);

/*
contract: smartContract instance of web3
fromAccount: where the money comes from ;) - an address, like web3.eth.defaultAccount
data: the bytecode of the smartcontract, taken from output.contracts[keyContract].bytecode
args: optional argument to pass to the constructor when the smartContract is deployed
*/
const web3 = await deploy(contract, fromAccount, data, args=[], gas=6000000, gasPrice=1);

//when you are lazy just like me ;)
const myContract = await compileDeploy(web3, pathFolder, pathContract, args, gas, gasprice);

Full example:


const { connect, compileDeploy } = require('tartufo');

const main = async () => {
    try {
        const socket = "ws://localhost:7545";
        const web3 = await connect(socket);
        
        const [ pathFolder, pathContract ] = [ 'contracts/', 'Example.sol'];
        
        const myContract = await compileDeploy(web3, pathFolder, pathContract, [], 6000000, 1);

        const params = {
            from: web3.eth.defaultAccount,
            gas: 1000000},
            (error, result) => { /* ... */ }
        }

        myContract.methods.myMethod(123).call(params);

    } catch(err) {
        console.log(err);
    }
}

main();

Requirements

Node.js 6.3.1+

License

MIT