Skip to content

Latest commit

 

History

History
44 lines (35 loc) · 1.17 KB

README.md

File metadata and controls

44 lines (35 loc) · 1.17 KB

go-solc: Go Bindings for the Solidity Compiler

Go Reference Go Report Card

go-solc provides an easy way to compile Solidity contracts from Go.

go get github.com/lmittmann/go-solc

Getting Started

go-solc automatically downloads the specified version of the Solidity compiler from https://binaries.soliditylang.org and caches it at .solc/bin/.

Example test:

// contract_test.go
func TestContract(t *testing.T) {
    c := solc.New("0.8.21")
    contract, err := c.Compile("src", "Test",
        solc.WithOptimizer(&solc.Optimizer{Enabled: true, Runs: 999999}),
    )
    // ...
}

Example directory structure:

workspace/
├── .solc/
│   └── bin/ # cached solc binaries
│       └── solc_v0.8.21
├── src/
│   └── test.sol
├── contract_test.go
├── go.mod
└── go.sum

Warning

This package is pre-1.0. There might be breaking changes between minor versions.