Getting Started with Go
The IOTA SDK is currently in alpha. APIs, interfaces, and behavior may change without notice between releases. It is not yet recommended for production use.
The IOTA SDK Go bindings allow you to build high-performance applications that interact with the IOTA network using native Go code. These bindings wrap the core Rust SDK via a Foreign Function Interface (FFI).
Prerequisites
Before using the Go bindings, ensure you have:
- Go: Version 1.21 or higher.
- CGO: Enabled (required for the Rust-to-Go FFI layer).
Installation
- Pre-built (Recommended)
- Build from Source
Add the IOTA SDK to your Go project using go get:
go get github.com/iotaledger/iota-sdk-go
The package automatically includes pre-built native libraries for most modern operating systems (Windows, macOS, and Linux).
The iota-sdk-go package includes precompiled native libraries for common platforms such as Windows, macOS, and Linux. In most cases, installing the package with:
go get github.com/iotaledger/iota-sdk-go
will download a compatible binary automatically.
However, if a prebuilt binary is not available for your operating system or CPU architecture, you may need to build the SDK from source. In this case, a Rust toolchain is required.
To build the Go bindings locally, clone the SDK repository and build the bindings from the bindings/go directory:
git clone https://github.com/iotaledger/iota-rust-sdk.git
cd iota-rust-sdk/bindings/go
go build ./...
For additional setup instructions and platform-specific details, refer to the Go bindings README in the repository.
Quick Start Example
The following example demonstrates how to connect to the IOTA Devnet and retrieve the Chain ID.
1. Create a main.go file
Create a new file named main.go and paste the following code:
loading...
2. Run the code
In your terminal, run:
go run main.go
What's Next?
Now that you have connected to the network, you can explore more advanced features:
- Check Balances: Learn how to query coin balances for a specific address.
- Transactions: Build and sign Programmable Transaction Blocks (PTBs).
- Key Management: Use the SDK to generate and manage IOTA addresses.
View more comprehensive examples in the official Go examples directory.