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

@youbox/artifactor

v1.0.0-alpha.33

Published

A contract packager for YOUChain and Javascript

Downloads

7

Readme

@youbox/artifactor

This package saves contract artifacts into JSON files

const Artifactor = require("@youbox/artifactor");
const artifactor = new Artifactor(__dirname);
artifactor.save({/*...*/}); // => a promise saving MyContract.json to a given destination

👏

Features

  • Manages contract ABIs, binaries and deployed addresses, so you don't have to.
  • Packages up build artifacts into .json files, which can then be included in your project with a simple require.
  • Manages library addresses for linked libraries.

The artifactor can be used with @youbox/contract, which provides features above and beyond web3:

  • Synchronized transactions for better control flow: transactions won't be considered finished until you're guaranteed they've been mined.
  • Promises. No more callback hell. Works well with ES6 and async/await.
  • Default values for transactions, like from address or gas.
  • Returning logs, transaction receipt and transaction hash of every synchronized transaction.

Install

$ npm install @youbox/artifactor

Example

Here, we'll generate a .json files given a JSON object like @youbox/contract-schema. This will give us a file which we can later require into other projects and contexts.

const Artifactor = require("@youbox/artifactor");
const artifactor = new Artifactor(__dirname);

// See truffle-schema for more info: https://github.com/trufflesuite/truffle/tree/develop/packages/contract-schema
const contractData = {
  contractName: "...",        // String; optional.
  abi: ...,                   // Array; required.
  metadata: "...",            // String; optional.
  bytecode: "...",            // String; optional.
  "x-some-dependency": ...    // String, Number, Object, or Array: optional.
};

artifactor.save(contractData);
// The file ./MyContract.json now exists, which you can
// import into your project like any other Javascript file.

API

artifactor.save(contractData)

Save contract data as a .json file. Returns a Promise.

  • contractData: Object. Data that represents this contract:

    {
      contractName: "MyContract",   // String; optional. Defaults to "Contract".
      abi: ...,                     // Array; required.  Application binary interface.
      metadata: "...",              // String; optional. Contract metadata.
      bytecode: "...",              // String; optional. Contract-creation binary without resolve library links.
      deployedBytecode: "...",      // String; optional. On-chain deployed binary without resolve library links.
      sourceMap: "...",             // String; optional. Source mapping for bytecode.
      deployedSourceMap: "...",     // String; optional. Source mapping for deployedBytecode.
      source: "...",                // String; optional. Uncompiled source code for contract.
      sourcePath: "...",            // String; optional. File path for uncompiled source code.
      ast: ...,                     // Object; optional. JSON representation of contract source code, as output by compiler.
      legacyAST: ...,               // Object; optional. Legacy JSON representation of contract source code, as output by compiler.
      compiler: ...,                // Object; optional. Compiler "type" and "properties".
      networks: ...,                // Object; optional. Mapping of network ID keys to network object values (address information, links to other contract instances, and/or contract event logs).
      schemaVersion: "...",         // String; optional. Schema version used by contract object representation.
      updatedAt: "...",             // String; optional. Time contract object representation was generated/most recently updated.
      devdoc: "...",                // String; optional. Developer documentation.
      userdoc: "...",               // String; optional. User documentation.
      "x-custom-property": ...      // String, Number, Object, or Array: optional. Custom property. Keys must be prefixed with "x-".
    }

artifactor.saveAll(contracts)

Save many contracts to the filesystem at once. Returns a Promise.

  • contracts: Object. Keys are the contract names and the values are contractData objects, as in the save() function above:

    {
      "MyContract": {
        "abi": ...,
        "bytecode": "..."
      }
      "AnotherContract": {
        // ...
      }
    }

Running Tests

$ npm test

License

MIT