sdkgo

package module
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 5 Imported by: 2

README

Go sdk for CESS network

GitHub license Go Reference build Go Report Card

The go sdk implementation of the CESS network, which provides RPC calls, status queries, block transactions and other functions.

📝 Reporting Vulnerability

If you find any system errors or you have better suggestions, please submit an issue or PR, or join the CESS discord to communicate with us.

📢 Announcement

CESS test network rpc endpoints

wss://testnet-rpc0.cess.cloud/ws/
wss://testnet-rpc1.cess.cloud/ws/
wss://testnet-rpc2.cess.cloud/ws/

CESS test network bootstrap node

_dnsaddr.boot-bucket-testnet.cess.cloud

🚰 CESS test network faucet

https://testnet-faucet.cess.cloud/

🏗 Usage

To get the package use the standard:

go get -u "github.com/CESSProject/cess-go-sdk"

✅ Testing

To run test:

  1. Run a CESS node locally.

  2. Run the command

    go test -v
    

📖 Document

License

Licensed under Apache 2.0

Documentation

Index

Constants

View Source
const Version = "0.5.0.25"

SDK Version

Variables

View Source
var DefaultRpcAddrs = func(cfg *Config) error {
	rpcAddrs := []string{
		"wss://testnet-rpc0.cess.cloud/ws/",
		"wss://testnet-rpc1.cess.cloud/ws/",
		"wss://testnet-rpc2.cess.cloud/ws/",
	}
	return cfg.Apply(ConnectRpcAddrs(rpcAddrs))
}

DefaultRpcAddrs configures the default rpc address

View Source
var DefaultTimeout = func(cfg *Config) error {
	return cfg.Apply(TransactionTimeout(pattern.BlockInterval))
}

DefaultTimeout configures the default transaction waiting timeout

Functions

func New

func New(ctx context.Context, opts ...Option) (*chain.ChainClient, error)

New constructs a new sdk client with the given options, falling back on reasonable defaults. The defaults are:

- If no rpc address is provided, the sdk client uses the default address "wss://testnet-rpc0.cess.cloud/ws/"" or "wss://testnet-rpc1.cess.cloud/ws/";

- If no transaction timeout is provided, the sdk client uses the default timeout: time.Duration(time.Second * 6)

- The serviceName is used to specify the name of your service Warning:

cess-bucket (cess storage service) must be set to bucket
DeOSS (cess decentralized object storage service) must be set to deoss
cess-cli (cess client) must be set to client

func NewWithoutDefaults

func NewWithoutDefaults(ctx context.Context, opts ...Option) (*chain.ChainClient, error)

NewWithoutDefaults constructs a new client with the given options but *without* falling back on reasonable defaults.

Warning: This function should not be considered a stable interface. We may choose to add required services at any time and, by using this function, you opt-out of any defaults we may provide.

Types

type Config

type Config = config.Config

Config describes a set of settings for the sdk.

type Option

type Option = config.Option

Option is a client config option that can be given to the client constructor

var FallbackDefaults Option = func(cfg *Config) error {
	for _, def := range defaults {
		if !def.fallback(cfg) {
			continue
		}
		if err := cfg.Apply(def.opt); err != nil {
			return err
		}
	}
	return nil
}

FallbackDefaults applies default options to the libp2p node if and only if no other relevant options have been applied. will be appended to the options passed into New.

func ConnectRpcAddrs

func ConnectRpcAddrs(s []string) Option

ConnectRpcAddrs configuration rpc address

func Mnemonic

func Mnemonic(mnemonic string) Option

Mnemonic configures the mnemonic of the signature account

func Name added in v0.4.1

func Name(name string) Option

Name configuration sdk name

func TransactionTimeout

func TransactionTimeout(timeout time.Duration) Option

TransactionTimeout configures the waiting timeout for a transaction

Directories

Path Synopsis
core
sdk
example
new

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL