sui-go-sdk is go language sdk for Project sui-go-sdk is project Sui SDK for Go programming language.
- You don't need to load your
sui.keystore
file if you just want to send some unsigned transactions. - File
sui.keystore
in config folder is test-only. Replace and load your own sui.keystore if your need to sign transactions. - PRs are open to everyone and let's build useful tools for Sui community!
- Load your keystore file and sign your messages with specific address.
- Provide methods
MoveCallAndExecuteTransaction
/BatchAndExecuteTransaction
. - Customized request method
SuiCall
. - Unsigned methods can be executed without loading your keystore file.
go get github.com/block-vision/sui-go-sdk
Golang Version |
---|
>= 1.17.3 |
package main
import (
"context"
"fmt"
"github.com/block-vision/sui-go-sdk/models"
"github.com/block-vision/sui-go-sdk/sui"
)
func main() {
// configure your endpoint here
cli := sui.NewSuiClient("https://fullnode.devnet.sui.io:443")
resp, err := cli.GetRecentTransactions(context.Background(), models.GetRecentTransactionRequest{
Count: 5,
})
if err != nil {
fmt.Println(err.Error())
}
fmt.Println(resp)
//If you want to request for original json response, you can use SuiCall().
rsp, err := cli.SuiCall(context.Background(), "sui_getRecentTransactions", 5)
if err != nil {
fmt.Println(err.Error())
}
fmt.Println(rsp)
keystoreCli, err := sui.SetAccountKeyStore("../sui.keystore.fortest")
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Println(keystoreCli.Keys())
fmt.Println(keystoreCli.GetKey("your-address"))
}
func main() {
cli := sui.NewSuiClient("https://fullnode.devnet.sui.io:443")
keystoreCli, err := sui.SetAccountKeyStore("../sui.keystore.fortest")
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Println(keystoreCli.Keys())
fmt.Println(keystoreCli.GetKey("your-address"))
resp, err := cli.MoveCall(context.Background(), models.MoveCallRequest{
Signer: "0x4d6f1a54e805038f44ecd3112927af147e9b9ecb",
PackageObjectId: "0x0000000000000000000000000000000000000002",
Module: "devnet_nft",
Function: "mint",
TypeArguments: []interface{}{},
Arguments: []interface{}{"blockvision", "blockvision", "testurl"},
Gas: "0x14802aeff2f444c888303f8fbba6d4e8451c38f8",
GasBudget: 1000,
})
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Println(resp)
}
func main() {
cli := sui.NewSuiClient("https://fullnode.devnet.sui.io:443")
keystoreCli, err := sui.SetAccountKeyStore("../sui.keystore.fortest")
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Println(keystoreCli.Keys())
fmt.Println(keystoreCli.GetKey("your-address"))
resp, err := cli.MoveCallAndExecuteTransaction(context.Background(), models.MoveCallAndExecuteTransactionRequest{
MoveCallRequest: models.MoveCallRequest{
Signer: "0x4d6f1a54e805038f44ecd3112927af147e9b9ecb",
PackageObjectId: "0x0000000000000000000000000000000000000002",
Module: "devnet_nft",
Function: "mint",
TypeArguments: []interface{}{},
Arguments: []interface{}{"blockvision", "blockvision", "testurl"},
Gas: "0x14802aeff2f444c888303f8fbba6d4e8451c38f8",
GasBudget: 1000,
},
})
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Println(resp)
}
Contributions are welcomed and greatly appreciated.
Please follow the PR/issue template.
Thank you to all the people who participate in building better infrastructure!