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 🙏

© 2025 – Pkg Stats / Ryan Hefner

demo-compile

v0.5.3

Published

Ethereum compiling for Democracy, tool for a distributed country

Downloads

370

Readme

demo-compile

Compiling management for EVM languages in the Democracy framework, initially only in Solidity.

  • Automatically includes OpenZeppelin contracts (in Solidity 0.5.x)
  • Flattens Solidity contracts into a single file for Etherscan verification, Remix compilation, and other online tools

Future goals include

  • adding multiple language support, such as or Huff macros for zero-knowledge validation and Vyper
  • support web3bindings to allow integrated GraphQL / IPFS / dataflow and workflow.
  • integrating into the Pipeline plugin on Remix for programmatic / reproducible builds
  • supporting EthPM, both pulling in packages and publishing packages

Installation

You can install and use demo-compile independently of the other Democracy packages.

yarn add demo-compile

or

npm install demo-compile

This also installs OpenZeppelin contracts into node_modules/openzeppelin-solidity/contracts either in your Yarn workspace or the local package, which is included in the search path for your contracts.

You can import those contracts automatically in your own as follows, where the relative path does not matter. All contract source filenames should be unique, and you can organize them arbitrarily into subfolders.

import "ERC20.sol"

Usage

const { Compiler, Flattener } = require('demo-compile');
const c = new Compiler({ startSourcePath: 'contracts' })
const output = await c.compile( 'ERC20.sol' )

Structure

demo-compile itself is a collection of components and a conventional pipeline for putting them together.

The pipeline moves from source files to compiled EVM bytecode and metadata, organized by contract name, that can then be linked and deployed by demo-depart

It includes four stages with a defined specification in between them.

  • Stage 1: Reading source files from storage
    • Output map has key: contract name, value: source contents
  • Stage 2: Reading cached compile outputs and comparing content hashes
    • Output map has key: contract name, value: source contents
  • Stage 3: Creating language-specific inputs and configs (e.g. solc)
    • Output map has key: contract name, value: contract output
  • Stage 4: Call the language-specific compiler
    • Output map: specific to the language
  • Stage 4: Writing compiler-specific outputs back to storage Formatting the language-specific output
    • Output map has key: contract name, value: contract output

demo-compile also makes use of the ContractsManager in demo-contract, which provide convenience methods for saving contract outputs to a Democracy (remote) key-value store.

  • getContract(contractName)
  • isCompile

Solidity Filename Convention

While a single Solidity file can contain multiple Solidity classes, we require the convention that a Solidity file named e.g. Booberry.sol contain only one class of the same name, called Booberry in this case.

Stage 1: Reading Source Files from Storage

const { findImports, requestedInputs } = getRequestedInputsFromDisk(sourceFileName, flattener)
const flattener = new Flattener()
getRequestedInputsFromDisk('ERC20.sol', new Flattener())

The single top-level filename and a fresh flattener object to pass into a findImports callback to collect imports for later flattening.

findImports(path) should return the source of a file as a long string, such as findImports('ERC20Mintable.sol') yields

and also adds it to the flattener via

flattener.addSource('ERC20Mintable.sol', fileContents)

requestedInputs is an Immutable Map with contract name keys and source content values.

return Map({
  contractName: fileContents
})

Stage 2: Comparing Content Hashes

getInputsToBuild(requestedInputs, existingOutputs)
return Map({
  contractName: fileContents
})

Stage 3: Language-Specific Inputs and Configs

get

Stage 4: Call the language-specific compiler

return Map({
  contractName: { abi: [{ ... }]
                  evm: {
                    bytecode: {  }
                  }
                }
})

Stage 5: Language-Specific Outputs

getCompileOutputFromSolc(outputContractsMap, requestedInputs, existingOutputs)
return Map({
})