Go bindings for the IOTA SDK, enabling Go developers to interact with the IOTA network.
To use the IOTA SDK in your Go project, add it as a dependency:
go get github.com/iotaledger/iota-sdk-goThe package includes pre-built native libraries for:
- macOS (x86_64 and ARM64)
- Linux (x86_64 and ARM64)
- Windows (x86_64 and ARM64)
Here is a simple example that queries the chain ID from the IOTA network:
package main
import (
"fmt"
"log"
"github.com/iotaledger/iota-sdk-go/iota_sdk"
)
func main() {
// Create a GraphQL client connected to devnet
client := iota_sdk.GraphQlClientNewDevnet()
// Query the chain ID
chainID, err := client.ChainId()
if err.(*iota_sdk.SdkFfiError) != nil {
log.Fatalf("Failed to get chain ID: %v", err)
}
fmt.Println("Chain ID:", chainID)
}The SDK provides GraphQL client functionality to interact with IOTA:
// Connect to devnet
client := iota_sdk.GraphQlClientNewDevnet()
// Connect to testnet
client := iota_sdk.GraphQlClientNewTestnet()
// Connect to mainnet
client := iota_sdk.GraphQlClientNewMainnet()
// Connect to a custom endpoint
client := iota_sdk.GraphQlClientNew("https://your-endpoint.com")More examples are available in the examples directory, including:
- Getting chain information
- Querying coin balances
- Working with transactions
- Managing addresses and keys
- And many more
If you want to build the Go bindings from the Rust source:
- GNU Make
- Go
- Rust toolchain
- uniffi-bindgen-go
Until NordSecurity/uniffi-bindgen-go#77 is merged, it is recommended to install uniffi-bindgen-go via:
cargo install uniffi-bindgen-go --git https://github.com/filament-dm/uniffi-bindgen-go --rev ab7315502bd6b979207fdae854e87d531ee8764dVerify by running make --version, go version, and uniffi-bindgen-go --version.
make gomake go-example chain_id