All Projects → portto → solana-go-sdk

portto / solana-go-sdk

Licence: MIT license
Solana Golang SDK

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to solana-go-sdk

arloader
Rust command line application and client for uploading files to Arweave.
Stars: ✭ 79 (-51.23%)
Mutual labels:  solana
solana-nft-monitor
Monitor Solana NFT projects using Github Actions + flatgithub.com
Stars: ✭ 31 (-80.86%)
Mutual labels:  solana
solana-nft-token-metadata-update
Node.js script to update NFT Token metadata on Solana Blockchain
Stars: ✭ 143 (-11.73%)
Mutual labels:  solana
anchor-escrow
Escrow program implemented in Anchor
Stars: ✭ 142 (-12.35%)
Mutual labels:  solana
metaboss
The Metaplex NFT-standard Swiss Army Knife tool.
Stars: ✭ 575 (+254.94%)
Mutual labels:  solana
cryptoplease-dart
Dart and Flutter apps and libraries maintained by Espresso Cash (Formerly Crypto Please) team for Solana.
Stars: ✭ 188 (+16.05%)
Mutual labels:  solana
swap-ui
React Component for Swapping on the Serum DEX
Stars: ✭ 107 (-33.95%)
Mutual labels:  solana
serum-vial
Real-time WebSocket market data API for Serum
Stars: ✭ 154 (-4.94%)
Mutual labels:  solana
app-monorepo
Secure, open source and community driven crypto wallet runs on all platforms and trusted by millions.
Stars: ✭ 1,282 (+691.36%)
Mutual labels:  solana
Solnet
Solana's .NET SDK and integration library.
Stars: ✭ 252 (+55.56%)
Mutual labels:  solana
rainbow
DeFi options comparator to detect market opportunities with CLI (Go) and web (Vue3).
Stars: ✭ 40 (-75.31%)
Mutual labels:  solana
strangemood
A decentralized marketplace for software licenses: an app store. Mostly for games.
Stars: ✭ 40 (-75.31%)
Mutual labels:  solana
solana-mobile-wallet
💳 Non-custodial cross-platform wallet for Solana
Stars: ✭ 64 (-60.49%)
Mutual labels:  solana
mango-v3-service
REST API Service for mango markets version 3
Stars: ✭ 29 (-82.1%)
Mutual labels:  solana
OpenLoginSdk
Pluggable auth infrastructure for Web3 wallets and dapps
Stars: ✭ 108 (-33.33%)
Mutual labels:  solana
MetaplexMetadata-js
Get the Metaplex Metadata from NFTs with Metaplex standard
Stars: ✭ 48 (-70.37%)
Mutual labels:  solana
awesome-defi
Curated list of awesome DeFi protocols, dapps, wallets and other resources
Stars: ✭ 36 (-77.78%)
Mutual labels:  solana
raydium-sdk
An SDK for building applications on top of Raydium.
Stars: ✭ 66 (-59.26%)
Mutual labels:  solana
wallet-adapter
Modular TypeScript wallet adapters and components for Solana applications.
Stars: ✭ 964 (+495.06%)
Mutual labels:  solana
alon
Remix for Solana.
Stars: ✭ 87 (-46.3%)
Mutual labels:  solana

Solana Go SDK

GitHub go.mod Go version GitHub release (latest SemVer)

Guide

Getting Started

Installing

go get -v github.com/portto/solana-go-sdk

Example

Hello World

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.MainnetRPCEndpoint)

	// If you would like to customize the http client used to make the
	// requests you could do something like this
	// c := client.New(rpc.WithEndpoint(rpc.MainnetRPCEndpoint),rpc.WithHTTPClient(customHTTPClient))

	resp, err := c.GetVersion(context.TODO())
	if err != nil {
		log.Fatalf("failed to version info, err: %v", err)
	}

	fmt.Println("version", resp.SolanaCore)
}

RPC

All interfaces of rpc follow the solana's json-rpc docs.

The implementation of client in this project separate into two parts, rpc and wrapped. The wrapped only returns main result value and the rpc returns whole rpc response. You can switch it by yourself for different situation. Take getBalance as example:

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.DevnetRPCEndpoint)

	// get balance
	balance, err := c.GetBalance(
		context.TODO(),
		"RNfp4xTbBb4C3kcv2KqtAj8mu4YhMHxqm1Skg9uchZ7",
	)
	if err != nil {
		log.Fatalf("failed to get balance, err: %v", err)
	}
	fmt.Printf("balance: %v\n", balance)

	// get balance with sepcific commitment
	balance, err = c.GetBalanceWithConfig(
		context.TODO(),
		"RNfp4xTbBb4C3kcv2KqtAj8mu4YhMHxqm1Skg9uchZ7",
		rpc.GetBalanceConfig{
			Commitment: rpc.CommitmentProcessed,
		},
	)
	if err != nil {
		log.Fatalf("failed to get balance with cfg, err: %v", err)
	}
	fmt.Printf("balance: %v\n", balance)

	// for advanced usage. fetch full rpc response
	res, err := c.RpcClient.GetBalance(
		context.TODO(),
		"RNfp4xTbBb4C3kcv2KqtAj8mu4YhMHxqm1Skg9uchZ7",
	)
	if err != nil {
		log.Fatalf("failed to get balance via rpc client, err: %v", err)
	}
	fmt.Printf("response: %+v\n", res)
}

Programing model & Program

There are some important tpyes in solana.

  • Program

resides in the program/ folder.

  • Pubkey (a basic identity of key)

resides in the common/ folder.

  • Insturciton (contain many pubkeys and program ID)
  • Message (contain many instructions)
  • Transaction (contain a message and many signatures)
  • Account (a pub/pri keypair )

reside in the types/ folder.

More Example

for more examples, follow examples/ folder

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].