solana-go-sdk

所属分类:区块链开发
开发工具:GO
文件大小:357KB
下载次数:0
上传日期:2023-03-14 21:31:47
上 传 者sh-1993
说明:  solana go sdk,索拉纳果朗sdk
(solana-go-sdk,Solana Golang SDK)

文件列表:
LICENSE (1063, 2023-03-06)
client (0, 2023-03-06)
client\client.go (7484, 2023-03-06)
client\client_test.go (33332, 2023-03-06)
client\rpc.go (1714, 2023-03-06)
client\rpc_get_account_info.go (3365, 2023-03-06)
client\rpc_get_account_info_test.go (14036, 2023-03-06)
client\rpc_get_balance.go (1768, 2023-03-06)
client\rpc_get_balance_test.go (3157, 2023-03-06)
client\rpc_get_block_time.go (367, 2023-03-06)
client\rpc_get_block_time_test.go (1031, 2023-03-06)
client\rpc_get_cluster_node.go (1094, 2023-03-06)
client\rpc_get_cluster_node_test.go (1243, 2023-03-06)
client\rpc_get_fee_for_message.go (2445, 2023-03-06)
client\rpc_get_fee_for_message_test.go (8756, 2023-03-06)
client\rpc_get_first_available_block.go (416, 2023-03-06)
client\rpc_get_first_available_block_test.go (568, 2023-03-06)
client\rpc_get_genesis_hash.go (329, 2023-03-06)
client\rpc_get_genesis_hash_test.go (622, 2023-03-06)
client\rpc_get_identity.go (371, 2023-03-06)
client\rpc_get_identity_test.go (704, 2023-03-06)
client\rpc_get_latest_blockhash.go (2157, 2023-03-06)
client\rpc_get_latest_blockhash_test.go (3771, 2023-03-06)
client\rpc_get_minimum_balance_for_rent_exemption.go (1168, 2023-03-06)
client\rpc_get_minimum_balance_for_rent_exemption_test.go (1354, 2023-03-06)
client\rpc_get_multiple_accounts.go (2827, 2023-03-06)
client\rpc_get_multiple_accounts_test.go (10613, 2023-03-06)
client\rpc_get_signatures_for_address.go (1120, 2023-03-06)
client\rpc_get_signatures_for_address_test.go (7302, 2023-03-06)
client\rpc_get_slot.go (772, 2023-03-06)
client\rpc_get_slot_test.go (1149, 2023-03-06)
... ...

Solana Go SDK

GitHub go.mod Go version GitHub release (latest SemVer)
# Guide ## Getting Started ### Installing ```sh go get -v github.com/portto/solana-go-sdk ``` ### Example #### Hello World ```go 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](https://docs.solana.com/developing/clients/jsonrpc-api). 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: ```go 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

近期下载者

相关文件


收藏者