huffc

package module
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2024 License: MIT Imports: 8 Imported by: 0

README

go-huffc: Go Bindings for the Huff Compiler

Go Reference Go Report Card

go-huffc provides an easy way to compile Huff contracts from Go.

[!NOTE] go-huffc requires the huffc binary to be installed. See huff.sh for installation instructions.

go get github.com/project-blanc/go-huffc

Getting Started

// Compile a contract with default compiler settings
c := huffc.New()
contract, err := c.Compile("contract.huff", nil)

// Compile a contract with custom compiler settings
c := huffc.New()
contract, err := c.Compile("contract.huff", &huffc.Options{
    EVMVersion: huffc.EVMVersionIstanbul,
})

Example Project

See the example project for a basic reference on how to test and fuzz a Huff contract in Go.

[!WARNING] This package is pre-1.0. There might be breaking changes between minor versions.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCompilationFailed = errors.New("compilation failed")
)

Functions

This section is empty.

Types

type Compiler

type Compiler struct {
	// contains filtered or unexported fields
}

Compiler represents a compiler for Huff contracts.

func New

func New() *Compiler

New returns a new instance of the compiler.

func (*Compiler) Compile

func (c *Compiler) Compile(filename string, opts *Options) (*Contract, error)

Compile the given huff-file with the given options and return the compiled contract.

type Contract

type Contract struct {
	Code       []byte // The runtime bytecode of the contract after deployment.
	DeployCode []byte // The bytecode to deploy the contract.
}

Contract represents a compiled contract.

type EVMVersion

type EVMVersion string

EVMVersion represents the EVM version to compile for.

const (
	EVMVersionShanghai EVMVersion = "shanghai"
	EVMVersionParis    EVMVersion = "paris"
)

type Options

type Options struct {
	EVMVersion EVMVersion // EVM version to compile for (default: shanghai)
}

Options for the Compiler. A zero Options consists entirely of default values.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL