{"id":13409176,"url":"https://github.com/gagliardetto/solana-go","last_synced_at":"2025-04-10T22:29:38.749Z","repository":{"id":37478825,"uuid":"381333195","full_name":"gagliardetto/solana-go","owner":"gagliardetto","description":"Go SDK library and RPC client for the Solana Blockchain","archived":false,"fork":false,"pushed_at":"2025-03-14T20:26:48.000Z","size":3615,"stargazers_count":1244,"open_issues_count":125,"forks_count":337,"subscribers_count":17,"default_branch":"main","last_synced_at":"2025-04-10T13:17:11.436Z","etag":null,"topics":["blockchain","golang","rpc","sdk","solana"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gagliardetto.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-29T10:58:58.000Z","updated_at":"2025-04-10T11:05:43.000Z","dependencies_parsed_at":"2024-01-08T14:30:56.875Z","dependency_job_id":"c92308b3-0d86-4454-a81a-3793c63f36fe","html_url":"https://github.com/gagliardetto/solana-go","commit_stats":{"total_commits":716,"total_committers":51,"mean_commits":14.03921568627451,"dds":"0.35474860335195535","last_synced_commit":"c7a7525bd05bdb366577b9fc7511cad60cfe5ba0"},"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gagliardetto%2Fsolana-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gagliardetto%2Fsolana-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gagliardetto%2Fsolana-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gagliardetto%2Fsolana-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gagliardetto","download_url":"https://codeload.github.com/gagliardetto/solana-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248308729,"owners_count":21082069,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","golang","rpc","sdk","solana"],"created_at":"2024-07-30T20:00:58.619Z","updated_at":"2025-04-10T22:29:38.723Z","avatar_url":"https://github.com/gagliardetto.png","language":"Go","funding_links":[],"categories":["Resources","Blockchain","区块链","Uncategorized"],"sub_categories":["Official Resources"],"readme":"# Solana SDK library for Go\n\n[![GoDoc](https://pkg.go.dev/badge/github.com/gagliardetto/solana-go?status.svg)](https://pkg.go.dev/github.com/gagliardetto/solana-go@v1.12.0?tab=doc)\n[![GitHub tag (latest SemVer pre-release)](https://img.shields.io/github/v/tag/gagliardetto/solana-go?include_prereleases\u0026label=release-tag)](https://github.com/gagliardetto/solana-go/releases)\n[![Build Status](https://github.com/gagliardetto/solana-go/workflows/tests/badge.svg?branch=main)](https://github.com/gagliardetto/solana-go/actions?query=branch%3Amain)\n[![TODOs](https://badgen.net/https/api.tickgit.com/badgen/github.com/gagliardetto/solana-go/main)](https://www.tickgit.com/browse?repo=github.com/gagliardetto/solana-go\u0026branch=main)\n[![Go Report Card](https://goreportcard.com/badge/github.com/gagliardetto/solana-go)](https://goreportcard.com/report/github.com/gagliardetto/solana-go)\n\nGo library to interface with Solana JSON RPC and WebSocket interfaces.\n\nMore contracts to come.\n\n**If you're using/developing Solana programs written in [Anchor Framework](https://github.com/project-serum/anchor), you can use [anchor-go](https://github.com/gagliardetto/anchor-go) to generate Golang clients**\n\n**If you're looking for a SERUM library, you can check out [gagliardetto/serum-go](https://github.com/gagliardetto/serum-go) ([./programs/serum](https://github.com/gagliardetto/solana-go/tree/main/programs/serum) is deprecated.**)\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"https://user-images.githubusercontent.com/15271561/128235229-1d2d9116-23bb-464e-b2cc-8fb6355e3b55.png\" margin=\"auto\" height=\"175\"/\u003e\n\u003c/div\u003e\n\n## Future Development\n\n`solana-go` is exclusively supported by my own time (which is money).\n\nIf my work has been useful in building your for-profit services/infra/bots/etc., consider donating at 8tTwBazKr2ST1b2kNrM7JMXwixRTvZicn7eRBihThymm (solana) to support future development.\n\nThanks!\n\n## Contents\n\n- [Solana SDK library for Go](#solana-sdk-library-for-go)\n  - [Contents' Index](#contents)\n  - [Features](#features)\n  - [Current development status](#current-development-status)\n  - [Requirements](#requirements)\n  - [Installation](#installation)\n  - [Pretty-Print transactions/instructions](#pretty-print-transactionsinstructions)\n  - [SendAndConfirmTransaction](#sendandconfirmtransaction)\n  - [Address Lookup Tables](#address-lookup-tables)\n  - [Decode an instruction data](#parsedecode-an-instruction-from-a-transaction)\n  - [Borsh encoding/decoding](#borsh-encodingdecoding)\n  - [ZSTD account data encoding](#zstd-account-data-encoding)\n  - [Custom Headers for authenticating with RPC providers](#custom-headers-for-authenticating-with-rpc-providers)\n  - [Working with rate-limited RPC providers](#working-with-rate-limited-rpc-providers)\n  - [Timeouts and Custom HTTP Clients](#timeouts-and-custom-http-clients)\n  - [Examples](#examples)\n    - [Create Account/Wallet](#create-account-wallet)\n    - [Load/parse keys](#loadparse-private-and-public-keys)\n    - [Transfer SOL from a wallet to another](#transfer-sol-from-one-wallet-to-another-wallet)\n    - [RPC (index)](#rpc-usage-examples)\n      - [RPC examples](#rpc-methods)\n      - [Websocket Subscription examples](#websocket-subscriptions)\n  - [Contributing](#contributing)\n  - [License](#license)\n  - [Credits](#credits)\n\n## Features\n\n- [x] [Full JSON RPC API](#rpc-usage-examples)\n- [x] Full WebSocket JSON streaming API\n- [ ] Wallet, account, and keys management\n- [ ] Clients for native programs\n  - [x] [system](/programs/system)\n  - [ ] config\n  - [ ] stake\n  - [ ] vote\n  - [x] BPF Loader\n  - [ ] Secp256k1\n- [ ] Clients for Solana Program Library (SPL)\n  - [x] [SPL token](/programs/token)\n  - [x] [associated-token-account](/programs/associated-token-account)\n  - [x] memo\n  - [ ] name-service\n  - [ ] ...\n- [ ] Client for Serum\n- [x] [Metaplex](https://github.com/gagliardetto/metaplex-go):\n  - [x] auction\n  - [x] metaplex\n  - [x] token-metadata\n  - [x] token-vault\n  - [x] nft-candy-machine\n- [ ] More programs\n\n## Current development status\n\nThere is currently **no stable release**. The SDK is actively developed and latest is `v1.12.0` which is an `alpha` release.\n\nThe RPC and WS client implementation is based on [this RPC spec](https://github.com/solana-labs/solana/blob/c2435363f39723cef59b91322f3b6a815008af29/docs/src/developing/clients/jsonrpc-api.md).\n\n## Note\n\n- solana-go is in active development, so all APIs are subject to change.\n- This code is unaudited. Use at your own risk.\n\n## Requirements\n\n- Go 1.19 or later\n\n## Installation\n\n```bash\n$ cd my-project\n$ go get github.com/gagliardetto/solana-go@v1.12.0\n```\n\n## Pretty-Print transactions/instructions\n\n![pretty-printed](https://user-images.githubusercontent.com/15271561/136708519-399c9498-3d20-48d6-89fa-bdf43aac6d83.png)\n\nInstructions can be pretty-printed with the `String()` method on a `Transaction`:\n\n```go\ntx, err := solana.NewTransaction(\n  []solana.Instruction{\n    system.NewTransferInstruction(\n      amount,\n      accountFrom.PublicKey(),\n      accountTo,\n    ).Build(),\n  },\n  recent.Value.Blockhash,\n  solana.TransactionPayer(accountFrom.PublicKey()),\n)\n\n...\n\n// Pretty print the transaction:\nfmt.Println(tx.String())\n// OR you can choose a destination and a title:\n// tx.EncodeTree(text.NewTreeEncoder(os.Stdout, \"Transfer SOL\"))\n```\n\n## SendAndConfirmTransaction\n\nYou can wait for a transaction confirmation using the `github.com/gagliardetto/solana-go/rpc/sendAndConfirmTransaction` package tools (for a complete example: [see here](#transfer-sol-from-one-wallet-to-another-wallet))\n\n```go\n// Send transaction, and wait for confirmation:\nsig, err := confirm.SendAndConfirmTransaction(\n  context.TODO(),\n  rpcClient,\n  wsClient,\n  tx,\n)\nif err != nil {\n  panic(err)\n}\nspew.Dump(sig)\n```\n\nThe above command will send the transaction, and wait for its confirmation.\n\n## Address Lookup Tables\n\nResolve lookups for a transaction:\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/davecgh/go-spew/spew\"\n\t\"github.com/gagliardetto/solana-go\"\n\tlookup \"github.com/gagliardetto/solana-go/programs/address-lookup-table\"\n\t\"github.com/gagliardetto/solana-go/rpc\"\n\t\"golang.org/x/time/rate\"\n)\n\nfunc main() {\n\tcluster := rpc.MainNetBeta\n\n\trpcClient := rpc.NewWithCustomRPCClient(rpc.NewWithLimiter(\n\t\tcluster.RPC,\n\t\trate.Every(time.Second), // time frame\n\t\t5,                       // limit of requests per time frame\n\t))\n\n\tversion := uint64(0)\n\ttx, err := rpcClient.GetTransaction(\n\t\tcontext.Background(),\n\t\tsolana.MustSignatureFromBase58(\"24jRjMP3medE9iMqVSPRbkwfe9GdPmLfeftKPuwRHZdYTZJ6UyzNMGGKo4BHrTu2zVj4CgFF3CEuzS79QXUo2CMC\"),\n\t\t\u0026rpc.GetTransactionOpts{\n\t\t\tMaxSupportedTransactionVersion: \u0026version,\n\t\t\tEncoding:                       solana.EncodingBase64,\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tparsed, err := tx.Transaction.GetTransaction()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tprocessTransactionWithAddressLookups(parsed, rpcClient)\n}\n\nfunc processTransactionWithAddressLookups(txx *solana.Transaction, rpcClient *rpc.Client) {\n\tif !txx.Message.IsVersioned() {\n\t\tfmt.Println(\"tx is not versioned; only versioned transactions can contain lookups\")\n\t\treturn\n\t}\n\ttblKeys := txx.Message.GetAddressTableLookups().GetTableIDs()\n\tif len(tblKeys) == 0 {\n\t\tfmt.Println(\"no lookup tables in versioned transaction\")\n\t\treturn\n\t}\n\tnumLookups := txx.Message.GetAddressTableLookups().NumLookups()\n\tif numLookups == 0 {\n\t\tfmt.Println(\"no lookups in versioned transaction\")\n\t\treturn\n\t}\n\tfmt.Println(\"num lookups:\", numLookups)\n\tfmt.Println(\"num tbl keys:\", len(tblKeys))\n\tresolutions := make(map[solana.PublicKey]solana.PublicKeySlice)\n\tfor _, key := range tblKeys {\n\t\tfmt.Println(\"Getting table\", key)\n\n\t\tinfo, err := rpcClient.GetAccountInfo(\n\t\t\tcontext.Background(),\n\t\t\tkey,\n\t\t)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tfmt.Println(\"got table \"+key.String())\n\n\t\ttableContent, err := lookup.DecodeAddressLookupTableState(info.GetBinary())\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tfmt.Println(\"table content:\", spew.Sdump(tableContent))\n\t\tfmt.Println(\"isActive\", tableContent.IsActive())\n\n\t\tresolutions[key] = tableContent.Addresses\n\t}\n\n\terr := txx.Message.SetAddressTables(resolutions)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\terr = txx.Message.ResolveLookups()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(txx.String())\n}\n```\n\n\n## Parse/decode an instruction from a transaction\n\n```go\npackage main\n\nimport (\n  \"context\"\n  \"encoding/base64\"\n  \"os\"\n  \"reflect\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  bin \"github.com/gagliardetto/binary\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/programs/system\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n  \"github.com/gagliardetto/solana-go/text\"\n)\n\nfunc main() {\n  exampleFromGetTransaction()\n}\n\nfunc exampleFromBase64() {\n  encoded := \"AfjEs3XhTc3hrxEvlnMPkm/cocvAUbFNbCl00qKnrFue6J53AhEqIFmcJJlJW3EDP5RmcMz+cNTTcZHW/WJYwAcBAAEDO8hh4VddzfcO5jbCt95jryl6y8ff65UcgukHNLWH+UQGgxCGGpgyfQVQV02EQYqm4QwzUt2qf9f1gVLM7rI4hwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA6ANIF55zOZWROWRkeh+lExxZBnKFqbvIxZDLE7EijjoBAgIAAQwCAAAAOTAAAAAAAAA=\"\n\n  data, err := base64.StdEncoding.DecodeString(encoded)\n  if err != nil {\n    panic(err)\n  }\n\n  // parse transaction:\n  tx, err := solana.TransactionFromDecoder(bin.NewBinDecoder(data))\n  if err != nil {\n    panic(err)\n  }\n\n  decodeSystemTransfer(tx)\n}\n\nfunc exampleFromGetTransaction() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  txSig := solana.MustSignatureFromBase58(\"3hZorctJtD3QLCRV3zF6JM6FDbFR5kAvsuKEG1RH9rWdz8YgnDzAvMWZFjdJgoL8KSNzZnx7aiExm1JEMC8KHfyy\")\n  {\n    out, err := client.GetTransaction(\n      context.TODO(),\n      txSig,\n      \u0026rpc.GetTransactionOpts{\n        Encoding: solana.EncodingBase64,\n      },\n    )\n    if err != nil {\n      panic(err)\n    }\n\n    tx, err := solana.TransactionFromDecoder(bin.NewBinDecoder(out.Transaction.GetBinary()))\n    if err != nil {\n      panic(err)\n    }\n\n    decodeSystemTransfer(tx)\n  }\n}\n\nfunc decodeSystemTransfer(tx *solana.Transaction) {\n  spew.Dump(tx)\n\n  // Get (for example) the first instruction of this transaction\n  // which we know is a `system` program instruction:\n  i0 := tx.Message.Instructions[0]\n\n  // Find the program address of this instruction:\n  progKey, err := tx.ResolveProgramIDIndex(i0.ProgramIDIndex)\n  if err != nil {\n    panic(err)\n  }\n\n  // Find the accounts of this instruction:\n  accounts, err := i0.ResolveInstructionAccounts(\u0026tx.Message)\n  if err != nil {\n    panic(err)\n  }\n\n  // Feed the accounts and data to the system program parser\n  // OR see below for alternative parsing when you DON'T know\n  // what program the instruction is for / you don't have a parser.\n  inst, err := system.DecodeInstruction(accounts, i0.Data)\n  if err != nil {\n    panic(err)\n  }\n\n  // inst.Impl contains the specific instruction type (in this case, `inst.Impl` is a `*system.Transfer`)\n  spew.Dump(inst)\n  if _, ok := inst.Impl.(*system.Transfer); !ok {\n    panic(\"the instruction is not a *system.Transfer\")\n  }\n\n  // OR\n  {\n    // There is a more general instruction decoder: `solana.DecodeInstruction`.\n    // But before you can use `solana.DecodeInstruction`,\n    // you must register a decoder for each program ID beforehand\n    // by using `solana.RegisterInstructionDecoder` (all solana-go program clients do it automatically with the default program IDs).\n    decodedInstruction, err := solana.DecodeInstruction(\n      progKey,\n      accounts,\n      i0.Data,\n    )\n    if err != nil {\n      panic(err)\n    }\n    // The returned `decodedInstruction` is the decoded instruction.\n    spew.Dump(decodedInstruction)\n\n    // decodedInstruction == inst\n    if !reflect.DeepEqual(inst, decodedInstruction) {\n      panic(\"they are NOT equal (this would never happen)\")\n    }\n\n    // To register other (not yet registered decoders), you can add them with\n    // `solana.RegisterInstructionDecoder` function.\n  }\n\n  {\n    // pretty-print whole transaction:\n    _, err := tx.EncodeTree(text.NewTreeEncoder(os.Stdout, text.Bold(\"TEST TRANSACTION\")))\n    if err != nil {\n      panic(err)\n    }\n  }\n}\n\n```\n\n## Borsh encoding/decoding\n\nYou can use the `github.com/gagliardetto/binary` package for encoding/decoding borsh-encoded data:\n\nDecoder:\n\n```go\n  resp, err := client.GetAccountInfo(\n    context.TODO(),\n    pubKey,\n  )\n  if err != nil {\n    panic(err)\n  }\n\n  borshDec := bin.NewBorshDecoder(resp.GetBinary())\n  var meta token_metadata.Metadata\n  err = borshDec.Decode(\u0026meta)\n  if err != nil {\n    panic(err)\n  }\n```\n\nEncoder:\n\n```go\nbuf := new(bytes.Buffer)\nborshEncoder := bin.NewBorshEncoder(buf)\nerr := borshEncoder.Encode(meta)\nif err != nil {\n  panic(err)\n}\n// fmt.Print(buf.Bytes())\n```\n\n## ZSTD account data encoding\n\nYou can request account data to be encoded with base64+zstd in the `Encoding` parameter:\n\n```go\nresp, err := client.GetAccountInfoWithOpts(\n  context.TODO(),\n  pubKey,\n  \u0026rpc.GetAccountInfoOpts{\n    Encoding:   solana.EncodingBase64Zstd,\n    Commitment: rpc.CommitmentFinalized,\n  },\n)\nif err != nil {\n  panic(err)\n}\nspew.Dump(resp)\n\nvar mint token.Mint\nerr = bin.NewDecoder(resp.GetBinary()).Decode(\u0026mint)\nif err != nil {\n  panic(err)\n}\nspew.Dump(mint)\n```\n\n## Working with rate-limited RPC providers\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"golang.org/x/time/rate\"\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  cluster := rpc.MainNetBeta\n  client := rpc.NewWithCustomRPCClient(rpc.NewWithLimiter(\n\t\tcluster.RPC,\n\t\trate.Every(time.Second), // time frame\n\t\t5,                       // limit of requests per time frame\n\t))\n\n  out, err := client.GetVersion(\n    context.TODO(),\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n## Custom Headers for authenticating with RPC providers\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"golang.org/x/time/rate\"\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  cluster := rpc.MainNetBeta\n  client := rpc.NewWithHeaders(\n    cluster.RPC,\n    map[string]string{\n      \"x-api-key\": \"...\",\n    },\n  )\n\n  out, err := client.GetVersion(\n    context.TODO(),\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\nThe data will **AUTOMATICALLY get decoded** and returned (**the right decoder will be used**) when you call the `resp.GetBinary()` method.\n\n## Timeouts and Custom HTTP Clients\n\nYou can use a timeout context:\n\n```go\nctx, cancel := context.WithTimeout(context.Background(), time.Second*3)\ndefer cancel()\nacc, err := rpcClient.GetAccountInfoWithOpts(\n  ctx,\n  accountID,\n  \u0026rpc.GetAccountInfoOpts{\n    Commitment: rpc.CommitmentProcessed,\n  },\n)\n```\n\nOr you can initialize the RPC client using a custom HTTP client using `rpc.NewWithCustomRPCClient`:\n\n```go\nimport (\n  \"net\"\n  \"net/http\"\n  \"time\"\n\n  \"github.com/gagliardetto/solana-go/rpc\"\n  \"github.com/gagliardetto/solana-go/rpc/jsonrpc\"\n)\n\nfunc NewHTTPTransport(\n  timeout time.Duration,\n  maxIdleConnsPerHost int,\n  keepAlive time.Duration,\n) *http.Transport {\n  return \u0026http.Transport{\n    IdleConnTimeout:     timeout,\n    MaxIdleConnsPerHost: maxIdleConnsPerHost,\n    Proxy:               http.ProxyFromEnvironment,\n    Dial: (\u0026net.Dialer{\n      Timeout:   timeout,\n      KeepAlive: keepAlive,\n    }).Dial,\n  }\n}\n\n// NewHTTP returns a new Client from the provided config.\nfunc NewHTTP(\n  timeout time.Duration,\n  maxIdleConnsPerHost int,\n  keepAlive time.Duration,\n) *http.Client {\n  tr := NewHTTPTransport(\n    timeout,\n    maxIdleConnsPerHost,\n    keepAlive,\n  )\n\n  return \u0026http.Client{\n    Timeout:   timeout,\n    Transport: tr,\n  }\n}\n\n// NewRPC creates a new Solana JSON RPC client.\nfunc NewRPC(rpcEndpoint string) *rpc.Client {\n  var (\n    defaultMaxIdleConnsPerHost = 10\n    defaultTimeout             = 25 * time.Second\n    defaultKeepAlive           = 180 * time.Second\n  )\n  opts := \u0026jsonrpc.RPCClientOpts{\n    HTTPClient: NewHTTP(\n      defaultTimeout,\n      defaultMaxIdleConnsPerHost,\n      defaultKeepAlive,\n    ),\n  }\n  rpcClient := jsonrpc.NewClientWithOpts(rpcEndpoint, opts)\n  return rpc.NewWithCustomRPCClient(rpcClient)\n}\n```\n\n## Examples\n\n### Create account (wallet)\n\n```go\npackage main\n\nimport (\n  \"context\"\n  \"fmt\"\n\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  // Create a new account:\n  account := solana.NewWallet()\n  fmt.Println(\"account private key:\", account.PrivateKey)\n  fmt.Println(\"account public key:\", account.PublicKey())\n\n  // Create a new RPC client:\n  client := rpc.New(rpc.TestNet_RPC)\n\n  // Airdrop 1 SOL to the new account:\n  out, err := client.RequestAirdrop(\n    context.TODO(),\n    account.PublicKey(),\n    solana.LAMPORTS_PER_SOL*1,\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n  fmt.Println(\"airdrop transaction signature:\", out)\n}\n```\n\n### Load/parse private and public keys\n\n```go\n{\n  // Load private key from a json file generated with\n  // $ solana-keygen new --outfile=standard.solana-keygen.json\n  privateKey, err := solana.PrivateKeyFromSolanaKeygenFile(\"/path/to/standard.solana-keygen.json\")\n  if err != nil {\n    panic(err)\n  }\n  fmt.Println(\"private key:\", privateKey.String())\n  // To get the public key, you need to call the `PublicKey()` method:\n  publicKey := privateKey.PublicKey()\n  // To get the base58 string of a public key, you can call the `String()` method:\n  fmt.Println(\"public key:\", publicKey.String())\n}\n\n{\n  // Load private key from base58:\n  {\n    privateKey, err := solana.PrivateKeyFromBase58(\"66cDvko73yAf8LYvFMM3r8vF5vJtkk7JKMgEKwkmBC86oHdq41C7i1a2vS3zE1yCcdLLk6VUatUb32ZzVjSBXtRs\")\n    if err != nil {\n      panic(err)\n    }\n    fmt.Println(\"private key:\", privateKey.String())\n    fmt.Println(\"public key:\", privateKey.PublicKey().String())\n  }\n  // OR:\n  {\n    privateKey := solana.MustPrivateKeyFromBase58(\"66cDvko73yAf8LYvFMM3r8vF5vJtkk7JKMgEKwkmBC86oHdq41C7i1a2vS3zE1yCcdLLk6VUatUb32ZzVjSBXtRs\")\n    _ = privateKey\n  }\n}\n\n{\n  // Generate a new key pair:\n  {\n    privateKey, err := solana.NewRandomPrivateKey()\n    if err != nil {\n      panic(err)\n    }\n    _ = privateKey\n  }\n  {\n    { // Generate a new private key (a Wallet struct is just a wrapper around a private key)\n      account := solana.NewWallet()\n      _ = account\n    }\n  }\n}\n\n{\n  // Parse a public key from a base58 string:\n  {\n    publicKey, err := solana.PublicKeyFromBase58(\"F8UvVsKnzWyp2nF8aDcqvQ2GVcRpqT91WDsAtvBKCMt9\")\n    if err != nil {\n      panic(err)\n    }\n    _ = publicKey\n  }\n  // OR:\n  {\n    publicKey := solana.MustPublicKeyFromBase58(\"F8UvVsKnzWyp2nF8aDcqvQ2GVcRpqT91WDsAtvBKCMt9\")\n    _ = publicKey\n  }\n}\n```\n\n### Transfer Sol from one wallet to another wallet\n\n```go\npackage main\n\nimport (\n  \"context\"\n  \"fmt\"\n  \"os\"\n  \"time\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/programs/system\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n  confirm \"github.com/gagliardetto/solana-go/rpc/sendAndConfirmTransaction\"\n  \"github.com/gagliardetto/solana-go/rpc/jsonrpc\"\n  \"github.com/gagliardetto/solana-go/rpc/ws\"\n  \"github.com/gagliardetto/solana-go/text\"\n)\n\nfunc main() {\n  // Create a new RPC client:\n  rpcClient := rpc.New(rpc.DevNet_RPC)\n\n  // Create a new WS client (used for confirming transactions)\n  wsClient, err := ws.Connect(context.Background(), rpc.DevNet_WS)\n  if err != nil {\n    panic(err)\n  }\n\n  // Load the account that you will send funds FROM:\n  accountFrom, err := solana.PrivateKeyFromSolanaKeygenFile(\"/path/to/.config/solana/id.json\")\n  if err != nil {\n    panic(err)\n  }\n  fmt.Println(\"accountFrom private key:\", accountFrom)\n  fmt.Println(\"accountFrom public key:\", accountFrom.PublicKey())\n\n  // The public key of the account that you will send sol TO:\n  accountTo := solana.MustPublicKeyFromBase58(\"TODO\")\n  // The amount to send (in lamports);\n  // 1 sol = 1000000000 lamports\n  amount := uint64(3333)\n\n  if true {\n    // Airdrop 1 sol to the account so it will have something to transfer:\n    out, err := rpcClient.RequestAirdrop(\n      context.TODO(),\n      accountFrom.PublicKey(),\n      solana.LAMPORTS_PER_SOL*1,\n      rpc.CommitmentFinalized,\n    )\n    if err != nil {\n      panic(err)\n    }\n    fmt.Println(\"airdrop transaction signature:\", out)\n    time.Sleep(time.Second * 5)\n  }\n  //---------------\n\n  recent, err := rpcClient.GetLatestBlockhash(context.TODO(), rpc.CommitmentFinalized)\n  if err != nil {\n    panic(err)\n  }\n\n  tx, err := solana.NewTransaction(\n    []solana.Instruction{\n      system.NewTransferInstruction(\n        amount,\n        accountFrom.PublicKey(),\n        accountTo,\n      ).Build(),\n    },\n    recent.Value.Blockhash,\n    solana.TransactionPayer(accountFrom.PublicKey()),\n  )\n  if err != nil {\n    panic(err)\n  }\n\n  _, err = tx.Sign(\n    func(key solana.PublicKey) *solana.PrivateKey {\n      if accountFrom.PublicKey().Equals(key) {\n        return \u0026accountFrom\n      }\n      return nil\n    },\n  )\n  if err != nil {\n    panic(fmt.Errorf(\"unable to sign transaction: %w\", err))\n  }\n  spew.Dump(tx)\n  // Pretty print the transaction:\n  tx.EncodeTree(text.NewTreeEncoder(os.Stdout, \"Transfer SOL\"))\n\n  // Send transaction, and wait for confirmation:\n  sig, err := confirm.SendAndConfirmTransaction(\n    context.TODO(),\n    rpcClient,\n    wsClient,\n    tx,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(sig)\n\n  // Or just send the transaction WITHOUT waiting for confirmation:\n  // sig, err := rpcClient.SendTransactionWithOpts(\n  //   context.TODO(),\n  //   tx,\n  //   false,\n  //   rpc.CommitmentFinalized,\n  // )\n  // if err != nil {\n  //   panic(err)\n  // }\n  // spew.Dump(sig)\n}\n\n```\n\n## RPC usage examples\n\n- [RPC Methods](#rpc-methods)\n  - [GetAccountInfo](#index--rpc--getaccountinfo)\n  - [GetBalance](#index--rpc--getbalance)\n  - [GetBlock](#index--rpc--getblock)\n  - [GetBlockCommitment](#index--rpc--getblockcommitment)\n  - [GetBlockHeight](#index--rpc--getblockheight)\n  - [GetBlockProduction](#index--rpc--getblockproduction)\n  - [GetBlockTime](#index--rpc--getblocktime)\n  - [GetBlocks](#index--rpc--getblocks)\n  - [GetBlocksWithLimit](#index--rpc--getblockswithlimit)\n  - [GetClusterNodes](#index--rpc--getclusternodes)\n  - [GetConfirmedBlock](#index--rpc--getconfirmedblock)\n    - **DEPRECATED: Please use [GetBlock](#index--rpc--getblock) instead** (This method is expected to be removed in **solana-core v2.0**)\n  - [GetConfirmedBlocks](#index--rpc--getconfirmedblocks)\n    - **DEPRECATED: Please use [GetBlocks](#index--rpc--getblocks) instead** (This method is expected to be removed in **solana-core v2.0**)\n  - [GetConfirmedBlocksWithLimit](#index--rpc--getconfirmedblockswithlimit)\n    - **DEPRECATED: Please use [GetBlocksWithLimit](#index--rpc--getblockswithlimit) instead** (This method is expected to be removed in **solana-core v2.0**)\n  - [GetConfirmedSignaturesForAddress2](#index--rpc--getconfirmedsignaturesforaddress2)\n    - **DEPRECATED: Please use [GetSignaturesForAddress](#index--rpc--getsignaturesforaddress) instead** (This method is expected to be removed in **solana-core v2.0**)\n  - [GetConfirmedTransaction](#index--rpc--getconfirmedtransaction)\n    - **DEPRECATED: Please use [GetTransaction](#index--rpc--gettransaction) instead** (This method is expected to be removed in **solana-core v2.0**)\n  - [GetEpochInfo](#index--rpc--getepochinfo)\n  - [GetEpochSchedule](#index--rpc--getepochschedule)\n  - [GetFeeCalculatorForBlockhash](#index--rpc--getfeecalculatorforblockhash)\n    - **DEPRECATED: Please use [IsBlockhashValid](#index--rpc--isblockhashvalid) or [GetFeeForMessage](#index--rpc--getfeeformessage) instead** (This method is expected to be removed in **solana-core v2.0**)\n  - [GetFeeRateGovernor](#index--rpc--getfeerategovernor) **DEPRECATED**\n  - [GetFees](#index--rpc--getfees)\n    - **DEPRECATED: Please use [GetFeeForMessage](#index--rpc--getfeeformessage) instead** (This method is expected to be removed in **solana-core v2.0**)\n  - [GetFeeForMessage](#index--rpc--getfeeformessage)\n  - [GetFirstAvailableBlock](#index--rpc--getfirstavailableblock)\n  - [GetGenesisHash](#index--rpc--getgenesishash)\n  - [GetHealth](#index--rpc--gethealth)\n  - [GetHighestSnapshotSlot](#index--rpc--gethighestsnapshotslot)\n  - [GetLatestBlockhash](#index--rpc--getlatestblockhash)\n  - [GetIdentity](#index--rpc--getidentity)\n  - [GetInflationGovernor](#index--rpc--getinflationgovernor)\n  - [GetInflationRate](#index--rpc--getinflationrate)\n  - [GetInflationReward](#index--rpc--getinflationreward)\n  - [GetLargestAccounts](#index--rpc--getlargestaccounts)\n  - [GetLeaderSchedule](#index--rpc--getleaderschedule)\n  - [GetMaxRetransmitSlot](#index--rpc--getmaxretransmitslot)\n  - [GetMaxShredInsertSlot](#index--rpc--getmaxshredinsertslot)\n  - [GetMinimumBalanceForRentExemption](#index--rpc--getminimumbalanceforrentexemption)\n  - [GetMultipleAccounts](#index--rpc--getmultipleaccounts)\n  - [GetProgramAccounts](#index--rpc--getprogramaccounts)\n  - [GetRecentBlockhash](#index--rpc--getrecentblockhash)\n    - To be used with **solana v1.8**\n    - For solana v1.9 or newer: **DEPRECATED: Please use [GetLatestBlockhash](#index--rpc--getlatestblockhash) instead** (This method is expected to be removed in **solana-core v2.0**)\n  - [GetRecentPerformanceSamples](#index--rpc--getrecentperformancesamples)\n  - [GetRecentPrioritizationFees](#index--rpc--getrecentprioritizationfees)\n  - [GetSignatureStatuses](#index--rpc--getsignaturestatuses)\n  - [GetSignaturesForAddress](#index--rpc--getsignaturesforaddress)\n  - [GetSlot](#index--rpc--getslot)\n  - [GetSlotLeader](#index--rpc--getslotleader)\n  - [GetSlotLeaders](#index--rpc--getslotleaders)\n  - [GetSnapshotSlot](#index--rpc--getsnapshotslot)\n    - **DEPRECATED: Please use [GetHighestSnapshotSlot](#index--rpc--gethighestsnapshotslot) instead** (This method is expected to be removed in **solana-core v2.0**)\n  - [GetStakeActivation](#index--rpc--getstakeactivation)\n  - [GetSupply](#index--rpc--getsupply)\n  - [GetTokenAccountBalance](#index--rpc--gettokenaccountbalance)\n  - [GetTokenAccountsByDelegate](#index--rpc--gettokenaccountsbydelegate)\n  - [GetTokenAccountsByOwner](#index--rpc--gettokenaccountsbyowner)\n  - [GetTokenLargestAccounts](#index--rpc--gettokenlargestaccounts)\n  - [GetTokenSupply](#index--rpc--gettokensupply)\n  - [GetTransaction](#index--rpc--gettransaction)\n  - [GetTransactionCount](#index--rpc--gettransactioncount)\n  - [GetVersion](#index--rpc--getversion)\n  - [GetVoteAccounts](#index--rpc--getvoteaccounts)\n  - [IsBlockhashValid](#index--rpc--isblockhashvalid)\n  - [MinimumLedgerSlot](#index--rpc--minimumledgerslot)\n  - [RequestAirdrop](#index--rpc--requestairdrop)\n  - [SendTransaction](#index--rpc--sendtransaction)\n  - [SimulateTransaction](#index--rpc--simulatetransaction)\n- [Websocket Subscriptions](#websocket-subscriptions)\n  - [AccountSubscribe](#index--ws-subscriptions--accountsubscribe)\n  - [LogsSubscribe](#index--ws-subscriptions--logssubscribe)\n  - [ProgramSubscribe](#index--ws-subscriptions--programsubscribe)\n  - [RootSubscribe](#index--ws-subscriptions--rootsubscribe)\n  - [SignatureSubscribe](#index--ws-subscriptions--signaturesubscribe)\n  - [SlotSubscribe](#index--ws-subscriptions--slotsubscribe)\n  - [VoteSubscribe](#index--ws-subscriptions--votesubscribe)\n\n### RPC Methods\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetAccountInfo\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  bin \"github.com/gagliardetto/binary\"\n  solana \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/programs/token\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.MainNetBeta_RPC\n  client := rpc.New(endpoint)\n\n  {\n    pubKey := solana.MustPublicKeyFromBase58(\"SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt\") // serum token\n    // basic usage\n    resp, err := client.GetAccountInfo(\n      context.TODO(),\n      pubKey,\n    )\n    if err != nil {\n      panic(err)\n    }\n    spew.Dump(resp)\n\n    var mint token.Mint\n    // Account{}.Data.GetBinary() returns the *decoded* binary data\n    // regardless the original encoding (it can handle them all).\n    err = bin.NewDecoder(resp.GetBinary()).Decode(\u0026mint)\n    if err != nil {\n      panic(err)\n    }\n    spew.Dump(mint)\n    // NOTE: The supply is mint.Supply, with the mint.Decimals:\n    // mint.Supply = 9998022451607088\n    // mint.Decimals = 6\n    // ... which means that the supply is 9998022451.607088\n  }\n  {\n    // Or you can use `GetAccountDataInto` which does all of the above in one call:\n    pubKey := solana.MustPublicKeyFromBase58(\"SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt\") // serum token\n    var mint token.Mint\n    // Get the account, and decode its data into the provided mint object:\n    err := client.GetAccountDataInto(\n      context.TODO(),\n      pubKey,\n      \u0026mint,\n    )\n    if err != nil {\n      panic(err)\n    }\n    spew.Dump(mint)\n  }\n  {\n    // // Or you can use `GetAccountDataBorshInto` which does all of the above in one call but for borsh-encoded data:\n    // var metadata token_metadata.Metadata\n    // // Get the account, and decode its data into the provided metadata object:\n    // err := client.GetAccountDataBorshInto(\n    //   context.TODO(),\n    //   pubKey,\n    //   \u0026metadata,\n    // )\n    // if err != nil {\n    //   panic(err)\n    // }\n    // spew.Dump(metadata)\n  }\n  {\n    pubKey := solana.MustPublicKeyFromBase58(\"4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R\") // raydium token\n    // advanced usage\n    resp, err := client.GetAccountInfoWithOpts(\n      context.TODO(),\n      pubKey,\n      // You can specify more options here:\n      \u0026rpc.GetAccountInfoOpts{\n        Encoding:   solana.EncodingBase64Zstd,\n        Commitment: rpc.CommitmentFinalized,\n        // You can get just a part of the account data by specify a DataSlice:\n        // DataSlice: \u0026rpc.DataSlice{\n        //  Offset: pointer.ToUint64(0),\n        //  Length: pointer.ToUint64(1024),\n        // },\n      },\n    )\n    if err != nil {\n      panic(err)\n    }\n    spew.Dump(resp)\n\n    var mint token.Mint\n    err = bin.NewDecoder(resp.GetBinary()).Decode(\u0026mint)\n    if err != nil {\n      panic(err)\n    }\n    spew.Dump(mint)\n  }\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetBalance\n\n```go\npackage main\n\nimport (\n  \"context\"\n  \"fmt\"\n  \"math/big\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.MainNetBeta_RPC\n  client := rpc.New(endpoint)\n\n  pubKey := solana.MustPublicKeyFromBase58(\"7xLk17EQQ5KLDLDe44wCmupJKJjTGd8hs3eSVVhCx932\")\n  out, err := client.GetBalance(\n    context.TODO(),\n    pubKey,\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n  spew.Dump(out.Value) // total lamports on the account; 1 sol = 1000000000 lamports\n\n  var lamportsOnAccount = new(big.Float).SetUint64(uint64(out.Value))\n  // Convert lamports to sol:\n  var solBalance = new(big.Float).Quo(lamportsOnAccount, new(big.Float).SetUint64(solana.LAMPORTS_PER_SOL))\n\n  // WARNING: this is not a precise conversion.\n  fmt.Println(\"◎\", solBalance.Text('f', 10))\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetBlock\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  example, err := client.GetLatestBlockhash(context.TODO(), rpc.CommitmentFinalized)\n  if err != nil {\n    panic(err)\n  }\n\n  {\n    out, err := client.GetBlock(context.TODO(), uint64(example.Context.Slot))\n    if err != nil {\n      panic(err)\n    }\n    // spew.Dump(out) // NOTE: This generates a lot of output.\n    spew.Dump(len(out.Transactions))\n  }\n\n  {\n    includeRewards := false\n    out, err := client.GetBlockWithOpts(\n      context.TODO(),\n      uint64(example.Context.Slot),\n      // You can specify more options here:\n      \u0026rpc.GetBlockOpts{\n        Encoding:   solana.EncodingBase64,\n        Commitment: rpc.CommitmentFinalized,\n        // Get only signatures:\n        TransactionDetails: rpc.TransactionDetailsSignatures,\n        // Exclude rewards:\n        Rewards: \u0026includeRewards,\n      },\n    )\n    if err != nil {\n      panic(err)\n    }\n    spew.Dump(out)\n  }\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetBlockCommitment\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  example, err := client.GetLatestBlockhash(context.TODO(), rpc.CommitmentFinalized)\n  if err != nil {\n    panic(err)\n  }\n\n  out, err := client.GetBlockCommitment(\n    context.TODO(),\n    uint64(example.Context.Slot),\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetBlockHeight\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetBlockHeight(\n    context.TODO(),\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetBlockProduction\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  {\n    out, err := client.GetBlockProduction(context.TODO())\n    if err != nil {\n      panic(err)\n    }\n    spew.Dump(out)\n  }\n  {\n    out, err := client.GetBlockProductionWithOpts(\n      context.TODO(),\n      \u0026rpc.GetBlockProductionOpts{\n        Commitment: rpc.CommitmentFinalized,\n        // Range: \u0026rpc.SlotRangeRequest{\n        //  FirstSlot: XXXXXX,\n        //  Identity:  solana.MustPublicKeyFromBase58(\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"),\n        // },\n      },\n    )\n    if err != nil {\n      panic(err)\n    }\n    spew.Dump(out)\n  }\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetBlockTime\n\n```go\npackage main\n\nimport (\n  \"context\"\n  \"time\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  example, err := client.GetLatestBlockhash(\n    context.TODO(),\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n\n  out, err := client.GetBlockTime(\n    context.TODO(),\n    uint64(example.Context.Slot),\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n  spew.Dump(out.Time().Format(time.RFC1123))\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetBlocks\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  example, err := client.GetLatestBlockhash(\n    context.TODO(),\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n\n  endSlot := uint64(example.Context.Slot)\n  out, err := client.GetBlocks(\n    context.TODO(),\n    uint64(example.Context.Slot-3),\n    \u0026endSlot,\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetBlocksWithLimit\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  example, err := client.GetLatestBlockhash(\n    context.TODO(),\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n\n  limit := uint64(4)\n  out, err := client.GetBlocksWithLimit(\n    context.TODO(),\n    uint64(example.Context.Slot-10),\n    limit,\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetClusterNodes\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetClusterNodes(\n    context.TODO(),\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetConfirmedBlock\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/AlekSi/pointer\"\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  example, err := client.GetLatestBlockhash(\n    context.TODO(),\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n\n  { // deprecated and is going to be removed in solana-core v1.8\n    out, err := client.GetConfirmedBlock(\n      context.TODO(),\n      uint64(example.Context.Slot),\n    )\n    if err != nil {\n      panic(err)\n    }\n    spew.Dump(out)\n  }\n  {\n    slot := uint64(example.Context.Slot)\n    out, err := client.GetConfirmedBlockWithOpts(\n      context.TODO(),\n      slot,\n      // You can specify more options here:\n      \u0026rpc.GetConfirmedBlockOpts{\n        Encoding:   solana.EncodingBase64,\n        Commitment: rpc.CommitmentFinalized,\n        // Get only signatures:\n        TransactionDetails: rpc.TransactionDetailsSignatures,\n        // Exclude rewards:\n        Rewards: pointer.ToBool(false),\n      },\n    )\n    if err != nil {\n      panic(err)\n    }\n    spew.Dump(out)\n  }\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetConfirmedBlocks\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  example, err := client.GetLatestBlockhash(\n    context.TODO(),\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n\n  {\n    endSlot := uint64(example.Context.Slot)\n    // deprecated and is going to be removed in solana-core v1.8\n    out, err := client.GetConfirmedBlocks(\n      context.TODO(),\n      uint64(example.Context.Slot-3),\n      \u0026endSlot,\n      rpc.CommitmentFinalized,\n    )\n    if err != nil {\n      panic(err)\n    }\n    spew.Dump(out)\n  }\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetConfirmedBlocksWithLimit\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  example, err := client.GetLatestBlockhash(\n    context.TODO(),\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n\n  limit := uint64(3)\n  { // deprecated and is going to be removed in solana-core v1.8\n    out, err := client.GetConfirmedBlocksWithLimit(\n      context.TODO(),\n      uint64(example.Context.Slot-10),\n      limit,\n      rpc.CommitmentFinalized,\n    )\n    if err != nil {\n      panic(err)\n    }\n    spew.Dump(out)\n  }\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetConfirmedSignaturesForAddress2\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  pubKey := solana.MustPublicKeyFromBase58(\"SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt\") // serum token\n  {\n    // deprecated and is going to be removed in solana-core v1.8\n    out, err := client.GetConfirmedSignaturesForAddress2(\n      context.TODO(),\n      pubKey,\n      // TODO:\n      nil,\n    )\n    if err != nil {\n      panic(err)\n    }\n    spew.Dump(out)\n  }\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetConfirmedTransaction\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  pubKey := solana.MustPublicKeyFromBase58(\"SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt\") // serum token\n  // Let's get a valid transaction to use in the example:\n  example, err := client.GetConfirmedSignaturesForAddress2(\n    context.TODO(),\n    pubKey,\n    nil,\n  )\n  if err != nil {\n    panic(err)\n  }\n\n  out, err := client.GetConfirmedTransaction(\n    context.TODO(),\n    example[0].Signature,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetEpochInfo\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetEpochInfo(\n    context.TODO(),\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetEpochSchedule\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetEpochSchedule(\n    context.TODO(),\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetFeeCalculatorForBlockhash\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  example, err := client.GetLatestBlockhash(\n    context.TODO(),\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n\n  out, err := client.GetFeeCalculatorForBlockhash(\n    context.TODO(),\n    example.Value.Blockhash,\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetFeeRateGovernor\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetFeeRateGovernor(\n    context.TODO(),\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetFees\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetFees(\n    context.TODO(),\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetFeeForMessage\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  example, err := client.GetFeeForMessage(\n    context.Background(),\n    \"AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA\",\n    rpc.CommitmentProcessed,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(example)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetFirstAvailableBlock\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetFirstAvailableBlock(\n    context.TODO(),\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetGenesisHash\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetGenesisHash(\n    context.TODO(),\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetHealth\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetHealth(\n    context.TODO(),\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n  spew.Dump(out == rpc.HealthOk)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetHighestSnapshotSlot\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  example, err := client.GetHighestSnapshotSlot(\n    context.Background(),\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(example)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetLatestBlockhash\n\nNEW: This method is only available in solana-core v1.9 or newer. Please use getRecentBlockhash for solana-core v1.8\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  example, err := client.GetLatestBlockhash(\n    context.Background(),\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(example)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetIdentity\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetIdentity(\n    context.TODO(),\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetInflationGovernor\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetInflationGovernor(\n    context.TODO(),\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetInflationRate\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetInflationRate(\n    context.TODO(),\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetInflationReward\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  pubKey := solana.MustPublicKeyFromBase58(\"6dmNQ5jwLeLk5REvio1JcMshcbvkYMwy26sJ8pbkvStu\")\n\n  out, err := client.GetInflationReward(\n    context.TODO(),\n    []solana.PublicKey{\n      pubKey,\n    },\n    \u0026rpc.GetInflationRewardOpts{\n      Commitment: rpc.CommitmentFinalized,\n    },\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetLargestAccounts\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetLargestAccounts(\n    context.TODO(),\n    rpc.CommitmentFinalized,\n    rpc.LargestAccountsFilterCirculating,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetLeaderSchedule\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetLeaderSchedule(\n    context.TODO(),\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out) // NOTE: this creates a lot of output\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetMaxRetransmitSlot\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetMaxRetransmitSlot(\n    context.TODO(),\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetMaxShredInsertSlot\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetMaxShredInsertSlot(\n    context.TODO(),\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetMinimumBalanceForRentExemption\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  dataSize := uint64(1024 * 9)\n  out, err := client.GetMinimumBalanceForRentExemption(\n    context.TODO(),\n    dataSize,\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetMultipleAccounts\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.MainNetBeta_RPC\n  client := rpc.New(endpoint)\n\n  {\n    out, err := client.GetMultipleAccounts(\n      context.TODO(),\n      solana.MustPublicKeyFromBase58(\"SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt\"),  // serum token\n      solana.MustPublicKeyFromBase58(\"4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R\"), // raydium token\n    )\n    if err != nil {\n      panic(err)\n    }\n    spew.Dump(out)\n  }\n  {\n    out, err := client.GetMultipleAccountsWithOpts(\n      context.TODO(),\n      []solana.PublicKey{solana.MustPublicKeyFromBase58(\"SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt\"), // serum token\n        solana.MustPublicKeyFromBase58(\"4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R\"), // raydium token\n      },\n      \u0026rpc.GetMultipleAccountsOpts{\n        Encoding:   solana.EncodingBase64Zstd,\n        Commitment: rpc.CommitmentFinalized,\n        // You can get just a part of the account data by specify a DataSlice:\n        // DataSlice: \u0026rpc.DataSlice{\n        //  Offset: pointer.ToUint64(0),\n        //  Length: pointer.ToUint64(1024),\n        // },\n      },\n    )\n    if err != nil {\n      panic(err)\n    }\n    spew.Dump(out)\n  }\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetProgramAccounts\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetProgramAccounts(\n    context.TODO(),\n    solana.MustPublicKeyFromBase58(\"metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s\"),\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(len(out))\n  spew.Dump(out) // NOTE: this can generate a lot of output\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetRecentBlockhash\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  // DEPRECATED: This method is only available in solana-core v1.8 or older. Please use getLatestBlockhash for solana-core v1.9 or newer.\n  recent, err := client.GetRecentBlockhash(\n    context.TODO(),\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(recent)\n}\n```\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetRecentPerformanceSamples\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  limit := uint(3)\n  out, err := client.GetRecentPerformanceSamples(\n    context.TODO(),\n    \u0026limit,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetRecentPrioritizationFees\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetRecentPrioritizationFees(\n    context.TODO(),\n    []solana.PublicKey{\n      solana.MustPublicKeyFromBase58(\"q5BgreVhTyBH1QCeriVb7kQYEPneanFXPLjvyjdf8M3\"),\n    },\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetSignatureStatuses\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetSignatureStatuses(\n    context.TODO(),\n    true,\n    // All the transactions you want the get the status for:\n    solana.MustSignatureFromBase58(\"2CwH8SqVZWFa1EvsH7vJXGFors1NdCuWJ7Z85F8YqjCLQ2RuSHQyeGKkfo1Tj9HitSTeLoMWnxpjxF2WsCH8nGWh\"),\n    solana.MustSignatureFromBase58(\"5YJHZPeHZuZjhunBc1CCB1NDRNf2tTJNpdb3azGsR7PfyEncCDhr95wG8EWrvjNXBc4wCKixkheSbCxoC2NCG3X7\"),\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetSignaturesForAddress\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetSignaturesForAddress(\n    context.TODO(),\n    solana.MustPublicKeyFromBase58(\"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA\"),\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetSlot\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetSlot(\n    context.TODO(),\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetSlotLeader\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetSlotLeader(\n    context.TODO(),\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetSlotLeaders\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  recent, err := client.GetLatestBlockhash(\n    context.TODO(),\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n\n  out, err := client.GetSlotLeaders(\n    context.TODO(),\n    uint64(recent.Context.Slot),\n    10,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetSnapshotSlot\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetSnapshotSlot(\n    context.TODO(),\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetStakeActivation\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  pubKey := solana.MustPublicKeyFromBase58(\"EW2p7QCJNHMVj5nQCcW7Q2BDETtNBXn68FyucU4RCjvb\")\n  out, err := client.GetStakeActivation(\n    context.TODO(),\n    pubKey,\n    rpc.CommitmentFinalized,\n    nil,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetSupply\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetSupply(\n    context.TODO(),\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetTokenAccountBalance\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  pubKey := solana.MustPublicKeyFromBase58(\"EzK5qLWhftu8Z2znVa5fozVtobbjhd8Gdu9hQHpC8bec\")\n  out, err := client.GetTokenAccountBalance(\n    context.TODO(),\n    pubKey,\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetTokenAccountsByDelegate\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  pubKey := solana.MustPublicKeyFromBase58(\"AfkALUPjQp8R1rUwE6KhT38NuTYWCncwwHwcJu7UtAfV\")\n  out, err := client.GetTokenAccountsByDelegate(\n    context.TODO(),\n    pubKey,\n    \u0026rpc.GetTokenAccountsConfig{\n      Mint: solana.MustPublicKeyFromBase58(\"So11111111111111111111111111111111111111112\"),\n    },\n    nil,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetTokenAccountsByOwner\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  bin \"github.com/gagliardetto/binary\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/programs/token\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  pubKey := solana.MustPublicKeyFromBase58(\"7HZaCWazgTuuFuajxaaxGYbGnyVKwxvsJKue1W4Nvyro\")\n  out, err := client.GetTokenAccountsByOwner(\n    context.TODO(),\n    pubKey,\n    \u0026rpc.GetTokenAccountsConfig{\n      Mint: solana.WrappedSol.ToPointer(),\n    },\n    \u0026rpc.GetTokenAccountsOpts{\n      Encoding: solana.EncodingBase64Zstd,\n    },\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n\n  {\n    tokenAccounts := make([]token.Account, 0)\n    for _, rawAccount := range out.Value {\n      var tokAcc token.Account\n\n      data := rawAccount.Account.Data.GetBinary()\n      dec := bin.NewBinDecoder(data)\n      err := dec.Decode(\u0026tokAcc)\n      if err != nil {\n        panic(err)\n      }\n      tokenAccounts = append(tokenAccounts, tokAcc)\n    }\n    spew.Dump(tokenAccounts)\n  }\n}\n\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetTokenLargestAccounts\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.MainNetBeta_RPC\n  client := rpc.New(endpoint)\n\n  pubKey := solana.MustPublicKeyFromBase58(\"SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt\") // serum token\n  out, err := client.GetTokenLargestAccounts(\n    context.TODO(),\n    pubKey,\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetTokenSupply\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.MainNetBeta_RPC\n  client := rpc.New(endpoint)\n\n  pubKey := solana.MustPublicKeyFromBase58(\"SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt\") // serum token\n  out, err := client.GetTokenSupply(\n    context.TODO(),\n    pubKey,\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetTransaction\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  txSig := solana.MustSignatureFromBase58(\"4bjVLV1g9SAfv7BSAdNnuSPRbSscADHFe4HegL6YVcuEBMY83edLEvtfjE4jfr6rwdLwKBQbaFiGgoLGtVicDzHq\")\n  {\n    out, err := client.GetTransaction(\n      context.TODO(),\n      txSig,\n      \u0026rpc.GetTransactionOpts{\n        Encoding: solana.EncodingBase64,\n      },\n    )\n    if err != nil {\n      panic(err)\n    }\n    spew.Dump(out)\n    spew.Dump(out.Transaction.GetBinary())\n\n    decodedTx, err := solana.TransactionFromDecoder(bin.NewBinDecoder(out.Transaction.GetBinary()))\n    if err != nil {\n      panic(err)\n    }\n    spew.Dump(decodedTx)\n  }\n  {\n    out, err := client.GetTransaction(\n      context.TODO(),\n      txSig,\n      nil,\n    )\n    if err != nil {\n      panic(err)\n    }\n    spew.Dump(out)\n    spew.Dump(out.Transaction.GetParsedTransaction())\n  }\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetTransactionCount\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetTransactionCount(\n    context.TODO(),\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetVersion\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetVersion(\n    context.TODO(),\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e GetVoteAccounts\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.GetVoteAccounts(\n    context.TODO(),\n    \u0026rpc.GetVoteAccountsOpts{\n      VotePubkey: solana.MustPublicKeyFromBase58(\"vot33MHDqT6nSwubGzqtc6m16ChcUywxV7tNULF19Vu\"),\n    },\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e IsBlockhashValid\n\n```go\npackage main\n\nimport (\n  \"context\"\n  \"fmt\"\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.MainNetBeta_RPC\n  client := rpc.New(endpoint)\n\n  blockHash := solana.MustHashFromBase58(\"J7rBdM6AecPDEZp8aPq5iPSNKVkU5Q76F3oAV4eW5wsW\")\n  out, err := client.IsBlockhashValid(\n    context.TODO(),\n    blockHash,\n    rpc.CommitmentFinalized,\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n  spew.Dump(out.Value) // true or false\n\n  fmt.Println(\"is blockhash valid:\", out.Value)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e MinimumLedgerSlot\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  out, err := client.MinimumLedgerSlot(\n    context.TODO(),\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e RequestAirdrop\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n)\n\nfunc main() {\n  endpoint := rpc.TestNet_RPC\n  client := rpc.New(endpoint)\n\n  amount := solana.LAMPORTS_PER_SOL // 1 sol\n  pubKey := solana.MustPublicKeyFromBase58(\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\")\n  out, err := client.RequestAirdrop(\n    context.TODO(),\n    pubKey,\n    amount,\n    \"\",\n  )\n  if err != nil {\n    panic(err)\n  }\n  spew.Dump(out)\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e SendTransaction\n\n```go\npackage main\n\nfunc main() {\n\n}\n```\n\n#### [index](#contents) \u003e [RPC](#rpc-methods) \u003e SimulateTransaction\n\n```go\npackage main\n\nfunc main() {\n\n}\n```\n\n### Websocket Subscriptions\n\n#### [index](#contents) \u003e [WS Subscriptions](#websocket-subscriptions) \u003e AccountSubscribe\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n  \"github.com/gagliardetto/solana-go/rpc/ws\"\n)\n\nfunc main() {\n  ctx := context.Background()\t\n  client, err := ws.Connect(context.Background(), rpc.MainNetBeta_WS)\n  if err != nil {\n    panic(err)\n  }\n  program := solana.MustPublicKeyFromBase58(\"9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin\") // serum\n\n  {\n    sub, err := client.AccountSubscribe(\n      program,\n      \"\",\n    )\n    if err != nil {\n      panic(err)\n    }\n    defer sub.Unsubscribe()\n\n    for {\n      got, err := sub.Recv(ctx)\n      if err != nil {\n        panic(err)\n      }\n      spew.Dump(got)\n    }\n  }\n  if false {\n    sub, err := client.AccountSubscribeWithOpts(\n      program,\n      \"\",\n      // You can specify the data encoding of the returned accounts:\n      solana.EncodingBase64,\n    )\n    if err != nil {\n      panic(err)\n    }\n    defer sub.Unsubscribe()\n\n    for {\n      got, err := sub.Recv(ctx)\n      if err != nil {\n        panic(err)\n      }\n      spew.Dump(got)\n    }\n  }\n}\n```\n\n#### [index](#contents) \u003e [WS Subscriptions](#websocket-subscriptions) \u003e LogsSubscribe\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n  \"github.com/gagliardetto/solana-go/rpc/ws\"\n)\n\nfunc main() {\n  ctx := context.Background()\t\n  client, err := ws.Connect(context.Background(), rpc.MainNetBeta_WS)\n  if err != nil {\n    panic(err)\n  }\n  program := solana.MustPublicKeyFromBase58(\"9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin\") // serum\n\n  {\n    // Subscribe to log events that mention the provided pubkey:\n    sub, err := client.LogsSubscribeMentions(\n      program,\n      rpc.CommitmentRecent,\n    )\n    if err != nil {\n      panic(err)\n    }\n    defer sub.Unsubscribe()\n\n    for {\n      got, err := sub.Recv(ctx)\n      if err != nil {\n        panic(err)\n      }\n      spew.Dump(got)\n    }\n  }\n  if false {\n    // Subscribe to all log events:\n    sub, err := client.LogsSubscribe(\n      ws.LogsSubscribeFilterAll,\n      rpc.CommitmentRecent,\n    )\n    if err != nil {\n      panic(err)\n    }\n    defer sub.Unsubscribe()\n\n    for {\n      got, err := sub.Recv(ctx)\n      if err != nil {\n        panic(err)\n      }\n      spew.Dump(got)\n    }\n  }\n}\n```\n\n#### [index](#contents) \u003e [WS Subscriptions](#websocket-subscriptions) \u003e ProgramSubscribe\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n  \"github.com/gagliardetto/solana-go/rpc/ws\"\n)\n\nfunc main() {\n  ctx := context.Background()\t\n  client, err := ws.Connect(context.Background(), rpc.MainNetBeta_WS)\n  if err != nil {\n    panic(err)\n  }\n  program := solana.MustPublicKeyFromBase58(\"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA\") // token\n\n  sub, err := client.ProgramSubscribeWithOpts(\n    program,\n    rpc.CommitmentRecent,\n    solana.EncodingBase64Zstd,\n    nil,\n  )\n  if err != nil {\n    panic(err)\n  }\n  defer sub.Unsubscribe()\n\n  for {\n    got, err := sub.Recv(ctx)\n    if err != nil {\n      panic(err)\n    }\n    spew.Dump(got)\n\n    decodedBinary := got.Value.Account.Data.GetBinary()\n    if decodedBinary != nil {\n      // spew.Dump(decodedBinary)\n    }\n\n    // or if you requested solana.EncodingJSONParsed and it is supported:\n    rawJSON := got.Value.Account.Data.GetRawJSON()\n    if rawJSON != nil {\n      // spew.Dump(rawJSON)\n    }\n  }\n}\n```\n\n#### [index](#contents) \u003e [WS Subscriptions](#websocket-subscriptions) \u003e RootSubscribe\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n  \"github.com/gagliardetto/solana-go/rpc/ws\"\n)\n\nfunc main() {\n  ctx := context.Background()\n  client, err := ws.Connect(context.Background(), rpc.TestNet_WS)\n  if err != nil {\n    panic(err)\n  }\n\n  sub, err := client.RootSubscribe()\n  if err != nil {\n    panic(err)\n  }\n\n  for {\n    got, err := sub.Recv(ctx)\n    if err != nil {\n      panic(err)\n    }\n    spew.Dump(got)\n  }\n}\n```\n\n#### [index](#contents) \u003e [WS Subscriptions](#websocket-subscriptions) \u003e SignatureSubscribe\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n  \"github.com/gagliardetto/solana-go/rpc/ws\"\n)\n\nfunc main() {\n  ctx := context.Background()\n  client, err := ws.Connect(context.Background(), rpc.TestNet_WS)\n  if err != nil {\n    panic(err)\n  }\n\n  txSig := solana.MustSignatureFromBase58(\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\")\n\n  sub, err := client.SignatureSubscribe(\n    txSig,\n    \"\",\n  )\n  if err != nil {\n    panic(err)\n  }\n  defer sub.Unsubscribe()\n\n  for {\n    got, err := sub.Recv(ctx)\n    if err != nil {\n      panic(err)\n    }\n    spew.Dump(got)\n  }\n}\n```\n\n#### [index](#contents) \u003e [WS Subscriptions](#websocket-subscriptions) \u003e SlotSubscribe\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n  \"github.com/gagliardetto/solana-go/rpc/ws\"\n)\n\nfunc main() {\n  ctx := context.Background()\n  client, err := ws.Connect(context.Background(), rpc.TestNet_WS)\n  if err != nil {\n    panic(err)\n  }\n\n  sub, err := client.SlotSubscribe()\n  if err != nil {\n    panic(err)\n  }\n  defer sub.Unsubscribe()\n\n  for {\n    got, err := sub.Recv(ctx)\n    if err != nil {\n      panic(err)\n    }\n    spew.Dump(got)\n  }\n}\n```\n\n#### [index](#contents) \u003e [WS Subscriptions](#websocket-subscriptions) \u003e VoteSubscribe\n\n```go\npackage main\n\nimport (\n  \"context\"\n\n  \"github.com/davecgh/go-spew/spew\"\n  \"github.com/gagliardetto/solana-go/rpc\"\n  \"github.com/gagliardetto/solana-go/rpc/ws\"\n)\n\nfunc main() {\n  ctx := context.Background()\n  client, err := ws.Connect(context.Background(), rpc.MainNetBeta_WS)\n  if err != nil {\n    panic(err)\n  }\n\n  // NOTE: this subscription must be enabled by the node you're connecting to.\n  // This subscription is disabled by default.\n  sub, err := client.VoteSubscribe()\n  if err != nil {\n    panic(err)\n  }\n  defer sub.Unsubscribe()\n\n  for {\n    got, err := sub.Recv(ctx)\n    if err != nil {\n      panic(err)\n    }\n    spew.Dump(got)\n  }\n}\n```\n\n## Contributing\n\nWe encourage everyone to contribute, submit issues, PRs, discuss. Every kind of help is welcome.\n\n## License\n\n[Apache 2.0](LICENSE)\n\n## Credits\n\n- Gopher logo was originally created by Takuya Ueda (https://twitter.com/tenntenn). Licensed under the Creative Commons 3.0 Attributions license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgagliardetto%2Fsolana-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgagliardetto%2Fsolana-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgagliardetto%2Fsolana-go/lists"}