Go SDK
The Go SDK targets backend services, indexers, monitoring tools, and other Go applications that need to interact with OXN. It provides both raw JSON-RPC access and encrypted-envelope construction.
Installation
go get github.com/oasisprotocol/oasis-sdk/client-sdk/go@latest
Or add to go.mod:
require (
github.com/oasisprotocol/oasis-sdk/client-sdk/go v0.13.0
)
Basic connection
package main
import (
"context"
"fmt"
"github.com/ethereum/go-ethereum/ethclient"
)
func main() {
ctx := context.Background()
client, err := ethclient.DialContext(ctx, "https://rpc.bout.network")
if err != nil {
panic(err)
}
chainID, _ := client.ChainID(ctx)
fmt.Println("Chain ID:", chainID)
}
Standard go-ethereum client works for read-only operations on plain data.
Sending encrypted transactions
For encrypted transactions, use the OXN Go client SDK wrapper (specific package path varies by version). The pattern:
- Fetch the enclave's public key from the network.
- Generate an ephemeral X25519 keypair.
- Encrypt calldata with Deoxys-II using the derived shared key.
- Wrap in CBOR envelope.
- Sign and send as a standard Ethereum transaction with
Data = envelope.
Consult the OXN Go SDK's readme for the current wrapper API. As of writing, the Go SDK exposes helper functions similar to the TypeScript wrappers.
Use cases
Backend service that acts on user behalf. A backend that signs transactions on user request. Standard Go signing with ethers-like patterns.
Indexer. A service that reads chain state and emits derived views. On OXN, an indexer sees only public metadata (from/to/gas/hashes) — the encrypted contract state is not visible to a general indexer without the callers' session keys.
Trading bot. Bots that watch for opportunities and submit transactions. On OXN, MEV strategies are limited because calldata is encrypted; the primary use case is arbitrage on plain (non-confidential) prices.
Monitoring / alerting. A service that watches transaction status, gas usage, and validator behavior. Standard Go tooling.
Address handling
Go SDK provides helpers for both native (oxn1…) and EVM (0x…) address formats:
// Bech32 encoding of a public key
nativeAddr, _ := oasis.NewNativeAddressFromPubkey(pubkey)
// Standard Ethereum address
evmAddr := crypto.PubkeyToAddress(pubkey)
Testing
Standard Go testing patterns apply. Integration tests hit the real OXN endpoint the same way TypeScript tests do:
func TestSomeIntegration(t *testing.T) {
if testing.Short() {
t.Skip("integration test")
}
// Connect to OXN Testnet, exercise the encrypted path
}
Next steps
- Rust SDK — for even higher-performance backends
- JSON-RPC API — raw protocol reference