Inspired by https://github.com/ethereum/solc-js, This browser solidity compiler works in your browser environments built with Reactjs, vueJS etc.
npm i @agnostico/browser-solidity-compiler
or with yarn
yarn add @agnostico/browser-solidity-compiler
import { solidityCompiler, getCompilerVersions } from "@agnostico/browser-solidity-compiler";
To load available solidity versions from https://binaries.soliditylang.org/bin/list.json
await getCompilerVersions()
This returns an object containing
- Release versions
- Latest release version
- Builds (releases + nightly versions)
await solidityCompiler({
version: `https://binaries.soliditylang.org/bin/${version}`,
contractBody: content,
options,
})
Name | Type | Required | Default |
---|---|---|---|
version | string |
Yes | |
contractBody | string |
Yes | |
options | object |
No | { } |
The options parameter currently ONLY supports the choice to add optimization
options.optimizer = {
enabled: boolean,
runs: number,
}