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
​
Copy link