The first community Go SDK for the Cedra network, with feature-parity with the official TypeScript SDK.
go get github.com/celerfi/cedra-go-kitpackage main
import (
"context"
"fmt"
"log"
"github.com/celerfi/cedra-go-kit/account"
"github.com/celerfi/cedra-go-kit/api"
"github.com/celerfi/cedra-go-kit/client"
"github.com/celerfi/cedra-go-kit/transaction"
)
func main() {
ctx := context.Background()
cedra := api.NewCedra(client.Testnet)
// Generate a new account
alice, err := account.GenerateEd25519Account()
if err != nil {
log.Fatal(err)
}
fmt.Println("Address:", alice.Address().Hex())
// Fund via faucet (testnet/devnet only)
if err := cedra.Faucet.FundAccount(ctx, alice.Address().Hex(), 100_000_000); err != nil {
log.Fatal(err)
}
// Check balance
balance, err := cedra.Account.GetAccountCEDRABalance(ctx, alice.Address().Hex())
if err != nil {
log.Fatal(err)
}
fmt.Printf("Balance: %d octas\n", balance)
// Send CEDRA to another address
bob, _ := account.GenerateEd25519Account()
opts := cedra.Coin.TransferCEDRA(bob.Address(), 1_000_000, nil)
committed, err := cedra.SignAndSubmitTransaction(ctx, alice, opts)
if err != nil {
log.Fatal(err)
}
fmt.Println("Tx hash:", committed.Hash)
fmt.Println("Success:", committed.Success)
}| Network | Node API | Chain ID |
|---|---|---|
| Mainnet | Coming Soon | TBD |
| Testnet | https://testnet.cedra.dev/v1 | TBD |
| Devnet | https://devnet.cedra.dev/v1 | TBD |
| Local | http://127.0.0.1:8080/v1 | 4 |
// Use a specific network
cedra := api.NewCedra(client.Mainnet)
// Or bring your own config
cfg := client.Config{
Network: client.Testnet,
NodeURL: "https://my-node.example.com/v1",
IndexerURL: "https://my-indexer.example.com/v1/graphql",
Timeout: 15 * time.Second,
}
cedra := api.NewCedraWithConfig(cfg)// Ed25519 (default, recommended)
alice, _ := account.GenerateEd25519Account()
alice, _ := account.NewEd25519AccountFromHex("0xYOUR_PRIVATE_KEY")
// SingleKey / Secp256k1
bob, _ := account.GenerateSingleKeyAccount()
bob, _ := account.NewSingleKeyAccountFromHex("0xYOUR_PRIVATE_KEY")| Package | Description |
|---|---|
api.GeneralAPI |
Ledger info, gas estimation, block queries, view functions |
api.AccountAPI |
Account data, resources, modules, balances, transactions |
api.TransactionAPI |
Build, simulate, submit, and wait for transactions |
api.EventAPI |
Query events by type, account, or creation number |
api.CoinAPI |
CEDRA and custom coin transfer builders |
api.FaucetAPI |
Fund accounts on testnet/devnet |
api.ANSAPI |
Resolve .cedra names to addresses and vice versa |
transaction |
BCS-correct transaction building and signing primitives |
bcs |
Binary Canonical Serialization encoder/decoder |
crypto |
Ed25519 and Secp256k1 key management |
rawTxn, err := cedra.Transaction.BuildTransaction(ctx, alice.Address(), transaction.BuildOptions{
Function: "0x1::cedra_account::transfer",
TypeArgs: []string{},
Args: [][]byte{
transaction.SerializeAddressArg(bobAddr),
transaction.SerializeU64Arg(500_000),
},
})
// Simulate first
simResults, _ := cedra.Transaction.SimulateTransaction(ctx, rawTxn, alice)
fmt.Println("Gas used:", simResults[0].GasUsed)
// Sign and submit
signedBytes, _ := transaction.SignTransaction(rawTxn, alice)
pending, _ := cedra.Transaction.SubmitTransaction(ctx, signedBytes)
committed, _ := cedra.WaitForTransaction(ctx, pending.Hash)feePayer, _ := account.NewEd25519AccountFromHex("0xFEE_PAYER_PRIVATE_KEY")
feePayerTxn, err := cedra.Transaction.BuildFeePayerTransaction(ctx, alice.Address(), transaction.BuildOptions{
Function: "0x1::cedra_account::transfer",
Args: [][]byte{
transaction.SerializeAddressArg(bobAddr),
transaction.SerializeU64Arg(500_000),
},
WithFeePayer: true,
})
senderAuthenticator, _ := transaction.SignFeePayerTransactionSenderAuthenticator(feePayerTxn, alice)
feePayerAuthenticator, _ := transaction.SignFeePayerTransactionFeePayerAuthenticator(feePayerTxn, feePayer)
signedBytes, _ := transaction.AssembleFeePayerSignedTransaction(
feePayerTxn,
senderAuthenticator,
feePayer.Address(),
feePayerAuthenticator,
)
pending, _ := cedra.Transaction.SubmitTransaction(ctx, signedBytes)
committed, _ := cedra.WaitForTransaction(ctx, pending.Hash)// Name -> address
addr, _ := cedra.ANS.GetAddressFromName(ctx, "alice.cedra")
// Address -> name
name, _ := cedra.ANS.GetNameFromAddress(ctx, "0x123...")MIT - Celerfi 2026