sdkgo

package module
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 4 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-rpc.cess.network/ws/

CESS test network bootstrap node

_dnsaddr.boot-miner-testnet.cess.network

🚰 CESS test network faucet

https://www.cess.network/faucet.html

🏗 Usage

To get the package use the standard:

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

✅ Testing

To run test:

make check

📖 Document

License

Licensed under Apache 2.0

Documentation

Index

Constants

View Source
const Version = "0.6.3"

SDK Version

Variables

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

DefaultRpcAddrs configures the default rpc address

View Source
var DefaultTimeout = func(cfg *Config) error {
	return cfg.Apply(TransactionTimeout(time.Second * 30))
}

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-rpc.cess.network/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

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 struct {
	Rpc      []string
	Mnemonic string
	Name     string
	Timeout  time.Duration
}

Config describes a set of settings for a client

func (*Config) Apply added in v0.6.0

func (cfg *Config) Apply(opts ...Option) error

Apply applies the given options to the config, returning the first error encountered (if any).

func (*Config) NewSDK added in v0.6.0

func (cfg *Config) NewSDK(ctx context.Context) (*chain.ChainClient, error)

NewSDK constructs a new client from the Config.

This function consumes the config. Do not reuse it (really!).

type Option

type Option func(cfg *Config) error

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
example
evm
new

Jump to

Keyboard shortcuts

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