Documentation ¶
Index ¶
- Constants
- Variables
- func Faucet(addr string) (err error)
- type Account
- func (acc *Account) Address() types.Address
- func (acc *Account) Balance(client *Client) (balance float64, err error)
- func (acc *Account) PrivateKey() string
- func (acc *Account) Sign(msg []byte) ([]byte, error)
- func (acc *Account) Transfer(client *Client, recipient types.Address, amount float64) (hash string, err error)
- type Client
- func (c *Client) Close()
- func (c *Client) ExecuteTransaction(ctx context.Context, txBytes string, signatureScheme SignatureScheme, ...) (response types.SuiExecuteTransactionResponse, err error)
- func (c *Client) ExecuteTransactionSerializedSig(ctx context.Context, txBytes string, signature string, ...) (response types.SuiExecuteTransactionResponse, err error)
- func (c *Client) GetCoinMetadata(ctx context.Context, coinType string) (metadata types.SuiCoinMetadata, err error)
- func (c *Client) GetCommitteeInfo(ctx context.Context, epoch *uint64) (info types.CommitteeInfo, err error)
- func (c *Client) GetEvents(ctx context.Context, query types.EventQuery, cursor *types.EventID, ...) (event *types.PaginatedEvents, err error)
- func (c *Client) GetGormalizedMoveModule(ctx context.Context, packagee types.ObjectID, module string) (moduleInfo types.SuiMoveNormalizedModule, err error)
- func (c *Client) GetMoveFunctionArgTypes(ctx context.Context, packagee types.ObjectID, module string, function string) (argTypes types.MoveFunctionArgTypes, err error)
- func (c *Client) GetNormalizedMoveFunction(ctx context.Context, packagee types.ObjectID, module string, function string) (functionInfo types.SuiMoveNormalizedFunction, err error)
- func (c *Client) GetNormalizedMoveModulesByPackage(ctx context.Context, packagee types.ObjectID) (modules map[string]*types.SuiMoveNormalizedModule, err error)
- func (c *Client) GetNormalizedMoveStruct(ctx context.Context, packagee types.ObjectID, module string, structt string) (structInfo types.SuiMoveNormalizedStruct, err error)
- func (c *Client) GetObject(ctx context.Context, objectID types.ObjectID) (objectData types.SuiObjectData, err error)
- func (c *Client) GetObjectsOwnedByAddress(ctx context.Context, address types.Address) (object []*types.SuiObjectInfo, err error)
- func (c *Client) GetObjectsOwnedByObject(ctx context.Context, objectID types.ObjectID) (object []*types.SuiObjectInfo, err error)
- func (c *Client) GetRawObject(ctx context.Context, objectID types.ObjectID) (object *types.SuiObjectData, err error)
- func (c *Client) GetTotalTransactionNumber(ctx context.Context) (number uint64, err error)
- func (c *Client) GetTransaction(ctx context.Context, transaction types.TransactionDigest) (response *types.SuiTransactionResponse, err error)
- func (c *Client) GetTransactionAuthSigners(ctx context.Context, transaction types.TransactionDigest) (response *types.SuiTransactionAuthSignersResponse, err error)
- func (c *Client) GetTransactions(ctx context.Context, query types.TransactionQuery, ...) (digests *types.PaginatedTransactionDigests, err error)
- func (c *Client) GetTransactionsInRange(ctx context.Context, start int64, end int64) (digests []types.TransactionDigest, err error)
- func (c *Client) MergeCoins(ctx context.Context, signer types.Address, primaryCoin types.ObjectID, ...) (bytes types.TransactionBytes, err error)
- func (c *Client) MoveCall(ctx context.Context, signer types.Address, packageObjectID types.ObjectID, ...) (bytes types.TransactionBytes, err error)
- func (c *Client) Pay(ctx context.Context, signer types.Address, inputCoins []types.ObjectID, ...) (bytes types.TransactionBytes, err error)
- func (c *Client) PayAllSui(ctx context.Context, signer types.Address, coins []types.ObjectID, ...) (bytes types.TransactionBytes, err error)
- func (c *Client) PaySui(ctx context.Context, signer types.Address, inputCoins []types.ObjectID, ...) (bytes types.TransactionBytes, err error)
- func (c *Client) Publish(ctx context.Context, signer types.Address, compiledModules []string, ...) (bytes types.TransactionBytes, err error)
- func (c *Client) SplitCoin(ctx context.Context, signer types.Address, coin types.ObjectID, ...) (bytes types.TransactionBytes, err error)
- func (c *Client) SplitCoinEqual(ctx context.Context, signer types.Address, coin types.ObjectID, ...) (bytes types.TransactionBytes, err error)
- func (c *Client) TransferObject(ctx context.Context, signer types.Address, objectID types.ObjectID, ...) (bytes types.TransactionBytes, err error)
- func (c *Client) TransferSui(ctx context.Context, signer types.Address, objectID types.ObjectID, ...) (bytes types.TransactionBytes, err error)
- type ExecuteTransactionRequestType
- type SignatureScheme
Constants ¶
const ( Devnet string = "https://fullnode.devnet.sui.io" Testnet string = "https://fullnode.testnet.sui.io:443" )
const ( ED25519 = SignatureScheme("ED25519") Secp256k1 = SignatureScheme("Secp256k1") )
const ( ImmediateReturn = ExecuteTransactionRequestType("ImmediateReturn") WaitForTxCert = ExecuteTransactionRequestType("WaitForTxCert") WaitForEffectsCert = ExecuteTransactionRequestType("WaitForEffectsCert") WaitForLocalExecution = ExecuteTransactionRequestType("WaitForLocalExecution") )
Variables ¶
var ( ErrNilClient = errors.New("client is nil") ErrNumber = errors.New("error number") )
var (
Endpoint string
)
Functions ¶
Types ¶
type Account ¶
type Account struct {
// contains filtered or unexported fields
}
func NewAccount ¶
func NewAccount() *Account
func NewAccountWithHexSeed ¶
func (*Account) PrivateKey ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client defines typed wrappers for the Sui RPC API.
func (*Client) ExecuteTransaction ¶
func (c *Client) ExecuteTransaction(ctx context.Context, txBytes string, signatureScheme SignatureScheme, signature string, pubkey types.PubKey, requestType ExecuteTransactionRequestType) (response types.SuiExecuteTransactionResponse, err error)
ExecuteTransaction execute the transaction and wait for results if desired. Request types: 1. ImmediateReturn: immediately returns a response to client without waiting for any execution results. Note the transaction may fail without being noticed by client in this mode.
After getting the response, the client may poll the node to check the result of the transaction.
2. WaitForTxCert: waits for TransactionCertificate and then return to client. 3. WaitForEffectsCert: waits for TransactionEffectsCert and then return to client. This mode is a proxy for transaction finality. 4. WaitForLocalExecution: waits for TransactionEffectsCert and make sure the node executed the transaction locally before returning the client. The local execution makes sure this node is aware of this transaction when client fires subsequent queries. However if the node fails to execute the transaction locally in a timely manner, a bool type in the response is set to false to indicated the case
func (*Client) ExecuteTransactionSerializedSig ¶
func (c *Client) ExecuteTransactionSerializedSig(ctx context.Context, txBytes string, signature string, requestType ExecuteTransactionRequestType) (response types.SuiExecuteTransactionResponse, err error)
ExecuteTransactionSerializedSig execute the transaction and wait for results if desired. use signature data directly
func (*Client) GetCoinMetadata ¶
func (c *Client) GetCoinMetadata(ctx context.Context, coinType string) (metadata types.SuiCoinMetadata, err error)
GetCoinMetadata return metadata(e.g., symbol, decimals) for a coin
func (*Client) GetCommitteeInfo ¶
func (c *Client) GetCommitteeInfo(ctx context.Context, epoch *uint64) (info types.CommitteeInfo, err error)
GetCommitteeInfo return the committee information for the asked epoch
func (*Client) GetGormalizedMoveModule ¶
func (c *Client) GetGormalizedMoveModule(ctx context.Context, packagee types.ObjectID, module string) (moduleInfo types.SuiMoveNormalizedModule, err error)
GetGormalizedMoveModule return a structured representation of Move module
func (*Client) GetMoveFunctionArgTypes ¶
func (c *Client) GetMoveFunctionArgTypes(ctx context.Context, packagee types.ObjectID, module string, function string) (argTypes types.MoveFunctionArgTypes, err error)
GetMoveFunctionArgTypes return the argument types of a Move function, based on normalized Type
func (*Client) GetNormalizedMoveFunction ¶
func (c *Client) GetNormalizedMoveFunction(ctx context.Context, packagee types.ObjectID, module string, function string) (functionInfo types.SuiMoveNormalizedFunction, err error)
GetNormalizedMoveFunction return a structured representation of Move function
func (*Client) GetNormalizedMoveModulesByPackage ¶
func (c *Client) GetNormalizedMoveModulesByPackage(ctx context.Context, packagee types.ObjectID) (modules map[string]*types.SuiMoveNormalizedModule, err error)
GetNormalizedMoveModulesByPackage return structured representations of all modules in the given package
func (*Client) GetNormalizedMoveStruct ¶
func (c *Client) GetNormalizedMoveStruct(ctx context.Context, packagee types.ObjectID, module string, structt string) (structInfo types.SuiMoveNormalizedStruct, err error)
GetNormalizedMoveStruct return a structured representation of Move struct
func (*Client) GetObject ¶
func (c *Client) GetObject(ctx context.Context, objectID types.ObjectID) (objectData types.SuiObjectData, err error)
GetObject the object information for a specified object
func (*Client) GetObjectsOwnedByAddress ¶
func (c *Client) GetObjectsOwnedByAddress(ctx context.Context, address types.Address) (object []*types.SuiObjectInfo, err error)
GetObjectsOwnedByAddress return the list of objects owned by an address
func (*Client) GetObjectsOwnedByObject ¶
func (c *Client) GetObjectsOwnedByObject(ctx context.Context, objectID types.ObjectID) (object []*types.SuiObjectInfo, err error)
GetObjectsOwnedByObject return the list of objects owned by an object
func (*Client) GetRawObject ¶
func (c *Client) GetRawObject(ctx context.Context, objectID types.ObjectID) (object *types.SuiObjectData, err error)
GetRawObject return the raw BCS serialized move object bytes for a specified object
func (*Client) GetTotalTransactionNumber ¶
GetTotalTransactionNumber return the total number of transactions known to the server
func (*Client) GetTransaction ¶
func (c *Client) GetTransaction(ctx context.Context, transaction types.TransactionDigest) (response *types.SuiTransactionResponse, err error)
GetTransaction return the transaction response object
func (*Client) GetTransactionAuthSigners ¶
func (c *Client) GetTransactionAuthSigners(ctx context.Context, transaction types.TransactionDigest) (response *types.SuiTransactionAuthSignersResponse, err error)
GetTransactionAuthSigners return the authority public keys that commits to the authority signature of the transaction
func (*Client) GetTransactions ¶
func (c *Client) GetTransactions(ctx context.Context, query types.TransactionQuery, cursor types.TransactionDigest, limit int64, descending bool) (digests *types.PaginatedTransactionDigests, err error)
GetTransactions return list of transactions for a specified query criteria
func (*Client) GetTransactionsInRange ¶
func (c *Client) GetTransactionsInRange(ctx context.Context, start int64, end int64) (digests []types.TransactionDigest, err error)
GetTransactionsInRange return list of transaction digests within the queried range
func (*Client) MergeCoins ¶
func (c *Client) MergeCoins(ctx context.Context, signer types.Address, primaryCoin types.ObjectID, coinToMerge types.ObjectID, gas types.ObjectID, gasBudget uint64) (bytes types.TransactionBytes, err error)
MergeCoins create an unsigned transaction to merge multiple coins into one coin
func (*Client) MoveCall ¶
func (c *Client) MoveCall(ctx context.Context, signer types.Address, packageObjectID types.ObjectID, module string, function string, typeArgs []string, args []json.RawMessage, gas types.ObjectID, gasBudget uint64) (bytes types.TransactionBytes, err error)
MoveCall create an unsigned transaction to execute a Move call on the network, by calling the specified function in the module of a given package
func (*Client) Pay ¶
func (c *Client) Pay(ctx context.Context, signer types.Address, inputCoins []types.ObjectID, recipients []string, amounts []int64, gas types.ObjectID, gasBudget uint64) (bytes types.TransactionBytes, err error)
Pay send Coin<T> to a list of addresses, where `T` can be any coin type, following a list of amounts, The object specified in the `gas` field will be used to pay the gas fee for the transaction. The gas object can not appear in `input_coins`. If the gas object is not specified, the RPC server will auto-select one
func (*Client) PayAllSui ¶
func (c *Client) PayAllSui(ctx context.Context, signer types.Address, coins []types.ObjectID, recipient types.Address, gasBudget uint64) (bytes types.TransactionBytes, err error)
PayAllSui send all SUI coins to one recipient. This is for SUI coin only and does not require a separate gas coin object. Specifically, what pay_all_sui does are: 1. accumulate all SUI from input coins and deposit all SUI to the first input coin 2. transfer the updated first coin to the recipient and also use this first coin as gas coin object. 3. the balance of the first input coin after tx is sum(input_coins) - actual_gas_cost. 4. all other input coins other than the first are deleted
func (*Client) PaySui ¶
func (c *Client) PaySui(ctx context.Context, signer types.Address, inputCoins []types.ObjectID, recipients []string, amounts []int64, gasBudget uint64) (bytes types.TransactionBytes, err error)
PaySui send SUI coins to a list of addresses, following a list of amounts. This is for SUI coin only and does not require a separate gas coin object. Specifically, what pay_sui does are: 1. debit each input_coin to create new coin following the order of amounts and assign it to the corresponding recipient. 2. accumulate all residual SUI from input coins left and deposit all SUI to the first input coin, then use the first input coin as the gas coin object. 3. the balance of the first input coin after tx is sum(input_coins) - sum(amounts) - actual_gas_cost 4. all other input coints other than the first one are deleted.
func (*Client) Publish ¶
func (c *Client) Publish(ctx context.Context, signer types.Address, compiledModules []string, gas types.ObjectID, gasBudget uint64) (bytes types.TransactionBytes, err error)
Publish create an unsigned transaction to publish Move module
func (*Client) SplitCoin ¶
func (c *Client) SplitCoin(ctx context.Context, signer types.Address, coin types.ObjectID, splitAmounts []int64, gas types.ObjectID, gasBudget uint64) (bytes types.TransactionBytes, err error)
SplitCoin create an unsigned transaction to split a coin object into multiple coins
func (*Client) SplitCoinEqual ¶
func (c *Client) SplitCoinEqual(ctx context.Context, signer types.Address, coin types.ObjectID, splitCount int64, gas types.ObjectID, gasBudget uint64) (bytes types.TransactionBytes, err error)
SplitCoinEqual create an unsigned transaction to split a coin object into multiple equal-size coins
func (*Client) TransferObject ¶
func (c *Client) TransferObject(ctx context.Context, signer types.Address, objectID types.ObjectID, recipient types.Address, gas types.ObjectID, gasBudget uint64) (bytes types.TransactionBytes, err error)
TransferObject create an unsigned transaction to transfer an object from one address to another. The object's type must allow public transfers
func (*Client) TransferSui ¶
func (c *Client) TransferSui(ctx context.Context, signer types.Address, objectID types.ObjectID, recipient types.Address, amount int64, gasBudget uint64) (bytes types.TransactionBytes, err error)
TransferSui create an unsigned transaction to send SUI coin object to a Sui address. The SUI object is also used as the gas object
type ExecuteTransactionRequestType ¶
type ExecuteTransactionRequestType string
type SignatureScheme ¶
type SignatureScheme string