anchor-go

command module
v0.0.0-...-8ffd212 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2025 License: MIT Imports: 14 Imported by: 0

README

anchor-go

anchor-go generates Go clients for Solana programs (smart contracts) written using the anchor framework. My anchor version is 0.31.0.

Installation

To install the anchor-go generator, you need to have Go installed on your system. Then, you can install the generator using the following command:

go install github.com/ysh0566/anchor-go@latest

Usage

To generate Go code from a Solana IDL file, use the following command:

anchor-go <path-to-idl-file> --package <package-name>

Note: This tool works well when the IDL includes discriminator fields.

Example

For example, to generate Go code for the counter example, you can run:

anchor-go examples/counter/counter.json --package counter

This will generate a Go file in the examples/counter directory.

Examples

You can find example IDL files and the generated Go code in the examples directory. Here are some examples:

  • examples/counter/counter.json - IDL file for the counter example.
  • examples/counter/counter.go - Generated Go code for the counter example.

Testing

To run tests for the generated code, use the following command:

go test ./...

This will run all tests in the project, including those in the examples directory.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
examples
counter
Code generated by anchor-go.
Code generated by anchor-go.
pumpfun
Code generated by anchor-go.
Code generated by anchor-go.

Jump to

Keyboard shortcuts

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