Go to file
Slavomir dd2d5478e9 Add RPC/getTransaction 2021-07-02 14:20:40 +02:00
cli Added license ot files 2020-11-09 13:09:50 -05:00
cmd/slnc Add serum math helper, and cleaned up test 2021-01-26 18:43:42 -05:00
diff serum: added order helper function 2021-02-18 09:32:37 -05:00
programs serum: export side 2021-02-18 09:42:56 -05:00
rpc Add RPC/getTransaction 2021-07-02 14:20:40 +02:00
testdata Added capabilities to read private key generated by `solana-keygen new` command line 2020-12-11 01:01:55 -05:00
text Refactor instruction that was not complying to AccountsSettable 2021-01-22 07:48:34 -05:00
vault wip 2020-11-25 14:25:32 -05:00
zap-box remove slnc dependancy 2020-11-11 08:21:44 -05:00
.envrc cleaned up error handling 2020-11-26 20:06:13 -05:00
.gitignore Add and ignore rpc/debug-utils.go 2021-06-30 21:04:40 +02:00
.goreleaser.yml Added license ot files 2020-11-09 13:09:50 -05:00
CHANGELOG.md Basic changelog info for first release 2020-11-09 11:24:41 -05:00
LICENSE A few touchups, README.md 2020-11-09 11:03:26 -05:00
README.md Fix readme instructions 2020-11-11 23:38:35 +08:00
account.go major refactor cli 2020-11-26 17:05:19 -05:00
account_test.go major refactor cli 2020-11-26 17:05:19 -05:00
go.mod Run go mod tidy 2021-06-30 23:39:23 +02:00
go.sum Run go mod tidy 2021-06-30 23:39:23 +02:00
init_test.go now able to decode EvenQueues 2020-11-17 07:14:55 -05:00
interface.go Rework the decode interface. 2021-01-20 13:21:09 -05:00
keys.go Added PublicKeyFromBytes and improved Equals (a fixed size slice on Go called an array can be compared with ==) 2020-12-18 14:58:49 -05:00
keys_test.go Added PublicKeyFromBytes and improved Equals (a fixed size slice on Go called an array can be compared with ==) 2020-12-18 14:58:49 -05:00
logging.go all test are passing 2020-11-13 08:39:04 -05:00
nativetype_test.go fix MustPublicKeyFromBase58 that was not panicing 2020-11-24 14:43:10 -05:00
nativetypes.go Add MustSignatureFromBase58 2021-07-01 22:00:09 +02:00
registry.go Added support for Serum DEX v3 instructions 2021-02-08 17:45:37 -05:00
transaction.go RPC: add getBlock 2021-06-30 23:35:30 +02:00
transaction_test.go Refactoring around Transaction, fixed all tests, skip WS tests for now 2020-12-16 15:34:07 -05:00
types.go Add RPC/getTransaction 2021-07-02 14:20:40 +02:00
types_test.go New text decoder 2020-11-20 14:24:07 -05:00
util.go Added license ot files 2020-11-09 13:09:50 -05:00

README.md

Solana library for Go

Go library to interface with Solana nodes's JSON-RPC interface, Solana's SPL tokens and the Serum DEX instructions. More contracts to come.

Installation

⚠️ solana-go works using SemVer but in 0 version, which means that the 'minor' will be changed when some broken changes are introduced into the application, and the 'patch' will be changed when a new feature with new changes is added or for bug fixing. As soon as v1.0.0 be released, solana-go will start to use SemVer as usual.

  1. Install from https://github.com/dfuse-io/solana-go/releases

or

  1. Install using Homebrew on macOS
$ brew install dfuse-io/tap/solana-go
  1. Build from source with:
$ go get -u -v github.com/dfuse-io/solana-go/cmd/slnc

Command-line

$ slnc get balance EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
1461600 lamports

$ slnc get account EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
{
  "lamports": 1461600,
  "data": [
    "AQAAABzjWe1aAS4E+hQrnHUaHF6Hz9CgFhuchf/TG3jN/Nj2gCa3xLwWAAAGAQEAAAAqnl7btTwEZ5CY/3sSZRcUQ0/AjFYqmjuGEQXmctQicw==",
    "base64"
  ],
  "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
  "executable": false,
  "rentEpoch": 108
}

$ slnc spl get mint SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt
Supply               9999647664800000
Decimals             6
No mint authority
No freeze authority

$ slnc serum list markets
...
ALEPH/USDT   EmCzMQfXMgNHcnRoFwAdPe1i2SuiSzMj1mx6wu3KN2uA
ALEPH/WUSDC  B37pZmwrwXHjpgvd9hHDAx1yeDsNevTnbbrN9W12BoGK
BTC/USDT     8AcVjMG2LTbpkjNoyq8RwysokqZunkjy3d5JDzxC6BJa
BTC/WUSDC    CAgAeMD7quTdnr6RPa7JySQpjf3irAmefYNdTb6anemq
ETH/USDT     HfCZdJ1wfsWKfYP2qyWdXTT5PWAGWFctzFjLH48U1Hsd
ETH/WUSDC    ASKiV944nKg1W9vsf7hf3fTsjawK6DwLwrnB2LH9n61c
SOL/USDT     8mDuvJJSgoodovMRYArtVVYBbixWYdGzR47GPrRT65YJ
SOL/WUSDC    Cdp72gDcYMCLLk3aDkPxjeiirKoFqK38ECm8Ywvk94Wi
...

$ slnc serum get market 7JCG9TsCx3AErSV3pvhxiW4AbkKRcJ6ZAveRmJwrgQ16
Price    Quantity  Depth
Asks
...
527.06   444.09    ####################
393.314  443.52    ###############
463.158  443.17    ###########
200      442.63    ######
234.503  442.54    ####
50       441.86    ##
61.563   441.47    #
84.377   440.98
-------  --------
10       439.96
193.303  439.24    ##
50       438.94    ##
0.5      438.87    ##
247.891  437.65    #####
458.296  436.99    #########
452.693  435.68    ##############
372.722  435.12    ##################
0.043    431.94    ##################
...

Library usage

Loading an SPL mint


import "github.com/dfuse-io/solana-go/rpc"
import "github.com/dfuse-io/solana-go/token"

	addr := solana.MustPublicKeyFromBase58("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v")
	cli := rpc.NewClient("http://api.mainnet-beta.solana.com/rpc")

	var m token.Mint
	err := cli.GetAccountDataIn(context.Background(), addr, &m)
	// handle `err`

	json.NewEncoder(os.Stdout).Encode(m)
	// {"OwnerOption":1,
	//  "Owner":"2wmVCSfPxGPjrnMMn7rchp4uaeoTqN39mXFC2zhPdri9",
	//  "Decimals":128,
	//  "IsInitialized":true}

Getting any account's data:


import "github.com/dfuse-io/solana-go/rpc"
import "github.com/dfuse-io/solana-go/token"

	addr := solana.MustPublicKeyFromBase58("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v")
	cli := rpc.NewClient("http://api.mainnet-beta.solana.com/rpc")

	acct, err := cli.GetAccountInfo(context.Background(), addr)
	// handle `err`

	json.NewEncoder(os.Stdout).Encode(m)
// {
//   "context": {
//     "Slot": 47836700
//   },
//   "value": {
//     "lamports": 1461600,
//     "data": {
//       "data": "AQAAABzjWe1aAS4E+hQrnHUaHF6Hz9CgFhuchf/TG3jN/Nj2gCa3xLwWAAAGAQEAAAAqnl7btTwEZ5CY/3sSZRcUQ0/AjFYqmjuGEQXmctQicw==",
//       "encoding": "base64"
//     },
//     "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
//     "executable": false,
//     "rentEpoch": 109
//   }
// }

Contributing

Any contributions are welcome, use your standard GitHub-fu to pitch in and improve.

License

Apache 2.0