Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lmittmann/go-solc
Go Bindings for the Solidity Compiler
https://github.com/lmittmann/go-solc
compiler ethereum golang smart-contracts solidity
Last synced: 2 months ago
JSON representation
Go Bindings for the Solidity Compiler
- Host: GitHub
- URL: https://github.com/lmittmann/go-solc
- Owner: lmittmann
- License: mit
- Created: 2023-01-22T17:56:28.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-11T21:27:46.000Z (3 months ago)
- Last Synced: 2024-10-20T00:04:57.581Z (3 months ago)
- Topics: compiler, ethereum, golang, smart-contracts, solidity
- Language: Go
- Homepage: https://pkg.go.dev/github.com/lmittmann/go-solc
- Size: 224 KB
- Stars: 16
- Watchers: 2
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `go-solc`: Go Bindings for the Solidity Compiler
[![Go Reference](https://pkg.go.dev/badge/github.com/lmittmann/go-solc.svg)](https://pkg.go.dev/github.com/lmittmann/go-solc)
[![Go Report Card](https://goreportcard.com/badge/github.com/lmittmann/go-solc)](https://goreportcard.com/report/github.com/lmittmann/go-solc)`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:
```go
// 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:
```bash
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.