import * as React from 'react'; import { hydrate, render } from 'react-dom'; import * as Loadable from 'react-loadable'; import { context } from 'ts/context/compiler'; import { Base } from 'ts/components/base'; import { Breakout } from 'ts/components/breakout'; import { CallToAction } from 'ts/components/call_to_action'; import { Code } from 'ts/components/code'; import { Compiler as CompilerComponent } from 'ts/components/compiler'; import { Content } from 'ts/components/content'; import { ContentBlock } from 'ts/components/content-block'; import { Hero } from 'ts/components/hero'; import { InlineCode } from 'ts/components/inline-code'; import { Lead } from 'ts/components/typography'; const Animation = Loadable({ loader: () => System.import(/* webpackChunkName: 'compiler-animation' */ 'ts/components/animations/compiler'), loading: () =>
, delay: 1000, render(loadable: { CompilerAnimation: any }): React.ReactNode { const Component = loadable.CompilerAnimation; returnnpm install @0x/sol-compiler --g
cd /your_project_dir && sol-compiler
Configure via a
mkdir compiler.json
Example of settings:
{`{
"contractsDir": "contracts",
"artifactsDir": "artifacts",
"contracts": "*",
"compilerSettings": {
"optimizer": { "enabled": false },
"outputSelection": {
"*": {
"*": ["abi", "evm.bytecode.object"]
}
}
}
}`}
In production, you want to optimize for a small bundle size, so your compiler.json config would instruct sol-compiler to only output the contract ABI.
{`{
"compilerSettings": {
"outputSelection": {
"*": {
"*": ["abi"]
}
}
}
}`}
{`{
"compilerOutput": {
"abi": [...],
},
}`}
In development, you need to use profiler and other dev tools that require more information from the artifact. To do this, you can specify that the artifact also contain the bytecode, deployed bytecode and source maps.
{`{
"compilerSettings": {
"outputSelection": {
"*": {
"*": [
"abi",
"evm.bytecode.object",
"evm.bytecode.sourceMap",
"evm.deployedBytecode.object",
"evm.deployedBytecode.sourceMap"
]
}
}
}
}`}
{`{
"compilerOutput": {
"abi": [...],
"evm": {
"bytecode": {
"object": "0xdeadbeef",
"sourceMap": "26:480:..."
},
"deployedBytecode": {
"object": "0xdeadbeef",
"sourceMap": "26:480:0..."
}
}
}
"sources": {
"Migrations.sol": {
"id": 0
}
},
}`}