/sol_build

🏗 Compile Solidity smart contracts with Deno

Primary LanguageTypeScriptMIT LicenseMIT

sol_build

Compile Solidity smart contracts with Deno.

Getting Started

Deno >=v1.25 is required.

To install sol_build globally run:

deno install --allow-read --allow-write --allow-net -f https://deno.land/x/sol_build/cli.ts

Initialize a new project with a sample hello.sol contract:

sol_build init helloworld
# Initializing a new project
# Fetching releases...
# Downloading soljson from https://solc-bin.ethereum.org/bin/soljson-v0.8.19+commit.7dd6d404.js...
cd helloworld

Compile all Solidity files and produce Hardhat-compatible artifacts with ABIs, EVM bytecode and more:

sol_build compile

If you only need ABIs, pass the --abi option. To run optimizations, pass the --optimizer <number of runs> flag.

Configuration

You can pass a custom config as a file with sol_build -c sol.config.ts if you need more flexible settings:

import type { Config } from 'https://deno.land/x/sol_build/config.ts'

export const config = {
  abi: true, // only produce ABIs
  // all solidity settings go here
}

CLI arguments have a higher priority over config except for outputSelection setting.

Programmatic use

sol_build exports functions for finding, linking and compiling Solidity files.

import { compileToFs } from 'https://deno.land/x/sol_build/mod.ts'
import { createRequire } from 'https://deno.land/std@0.177.0/node/module.ts'

const require = createRequire(import.meta.url)
const solc = solc = wrapper(require('./.solc.js'))

await compileToFs(solc, { optimizer: { enabled: true, runs: 200 }})