Cardano Client Lib for Go
The ccl Go package brings Cardano Client Lib (CCL)‘s offline Cardano operations — key derivation, address handling, transaction building and signing, Plutus data, governance keys — to Go as a native library. No JVM, no cgo, no C toolchain: the shared library is loaded at runtime with purego.
Documentation
Section titled “Documentation”| Document | Contents |
|---|---|
| API reference | Every type and method: Bridge, Account, Address, Crypto, Tx, Plutus, Script, Gov, Wallet, QuickTx |
| Building transactions | The full workflow with worked examples: payments, staking, governance, minting, Plutus |
| Providers & evaluators | Fetching UTXOs/protocol params from Yaci DevKit or Blockfrost; remote script-cost evaluation |
| Troubleshooting | Native library download & resolution, platform support, common errors |
| TxPlan (YAML) reference | The transaction description format used by QuickTx.Build — shared by all four language wrappers |
Installation
Section titled “Installation”go get github.com/bloxbean/cardano-client-bindings/wrappers/goimport "github.com/bloxbean/cardano-client-bindings/wrappers/go/ccl"Requires Go ≥ 1.21. On first use, the package downloads the prebuilt native library (libccl) for your platform from the project’s GitHub releases into your user cache directory (os.UserCacheDir()/cardano-client-bindings/<version>/) — a one-time, per-version download. No environment variables or build flags are needed.
To use a locally built library instead (or on a platform without prebuilt binaries), set CCL_LIB_PATH — see troubleshooting.
Quick start
Section titled “Quick start”package main
import ( "fmt" "log"
"github.com/bloxbean/cardano-client-bindings/wrappers/go/ccl")
func main() { bridge, err := ccl.New() if err != nil { log.Fatal(err) } defer bridge.Close()
// Create a new account (24-word mnemonic, testnet addresses). account, err := bridge.Account.Create(ccl.Testnet) if err != nil { log.Fatal(err) } fmt.Println(account.BaseAddress) // addr_test1... fmt.Println(account.StakeAddress) // stake_test1...
// Restore it later from the mnemonic. restored, _ := bridge.Account.FromMnemonic(account.Mnemonic, ccl.Testnet, 0, 0) _ = restored}Build, sign, and inspect a transaction — fully offline
Section titled “Build, sign, and inspect a transaction — fully offline”Transactions are described as a TxPlan YAML document. You supply the UTXOs and protocol parameters (from any source — see providers for ready-made ones), and get back an unsigned transaction:
yaml := fmt.Sprintf(`version: 1.0transaction: - tx: from: %s intents: - type: payment address: %s amounts: - unit: lovelace quantity: "5000000"`, sender.BaseAddress, receiver)
result, err := bridge.QuickTx.Build(yaml, utxos, protocolParams)// result.TxCbor, result.TxHash, result.Fee
signed, err := bridge.Account.SignTx(sender.Mnemonic, ccl.Testnet, 0, 0, result.TxCbor)// submit `signed` with any HTTP client — the library never talks to the networkWith a provider, fetching the chain data is one call:
provider := ccl.NewYaciProvider("") // local Yaci DevKit ("" = default URL)result, err := bridge.QuickTx.BuildWith(yaml, provider, sender.BaseAddress, 0)Design in one paragraph
Section titled “Design in one paragraph”The native library is offline and stateless — it derives, builds, signs, hashes, and serializes, but never performs I/O. Anything that touches the network (fetching UTXOs, protocol parameters, submitting transactions, remote script evaluation) lives in the wrapper or in your code, where you control HTTP. Plutus execution units are computed offline in-process (via Scalus) by default, so even script transactions build without a network connection.
Concurrency
Section titled “Concurrency”A *Bridge is safe to share across goroutines: all native calls are funneled to one dedicated, pinned OS thread (a GraalVM isolate thread is bound to the OS thread that created it), so calls are serialized. For parallel native work, create multiple Bridge instances. Always defer bridge.Close(); calls after Close return ccl.ErrBridgeClosed rather than crashing.
Networks
Section titled “Networks”ccl.Mainnet // 0ccl.Testnet // 1ccl.Preprod // 2ccl.Preview // 3Every key-derivation method takes a typed ccl.Network — passing a bare int is a compile error. Note the values are CCL enum ordinals, which are the inverse of Cardano’s on-chain network id for mainnet/testnet (Mainnet = 0, but a mainnet address’s on-chain network_id is 1). See API reference → Networks.
Examples
Section titled “Examples”Runnable examples live in wrappers/go/examples/:
examples/account— create/restore accounts, derive keys and DRep idexamples/primitives— mnemonics, Blake2b hashing, Ed25519 sign/verify, address parsingexamples/transaction— offline QuickTx build + signexamples/evaluator— Plutus mint with offline Scalus units vs. remote Blockfrost evaluation
go run ./examples/account