💻
Solana Go
GithubMissing content?
  • 🏠Introduction
  • 🛠️Prepare
  • Tour
    • Intro
    • Create Account
    • Request Airdrop
    • Get Balance (SOL)
    • Transfer (SOL)
    • Create Mint (Token)
    • Create Account (Token)
      • Random Token Account
      • Associated Token Account
    • Mint To (Token)
    • Get Balance (Token)
    • Transfer (Token)
  • Advanced
    • Durable Nonce
      • Create Nonce Account
      • Get Nonce Account
      • Use Nonce
  • Metaplex (NFT)
    • Get Metadata
  • Misc
    • Need To Know
Powered by GitBook
On this page

Was this helpful?

  1. Tour

Get Balance (SOL)

After you requesting some SOL, you can check how much you have.

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/portto/solana-go-sdk/client"
	"github.com/portto/solana-go-sdk/rpc"
)

func main() {
	c := client.NewClient(rpc.LocalnetRPCEndpoint)
	balance, err := c.GetBalance(
		context.Background(),
		"RNfp4xTbBb4C3kcv2KqtAj8mu4YhMHxqm1Skg9uchZ7",
	)
	if err != nil {
		log.Fatalln("get balance error", err)
	}
	fmt.Println(balance)
}

1 SOL = 10^9 lamports

PreviousRequest AirdropNextTransfer (SOL)

Last updated 3 years ago

Was this helpful?