Categorygithub.com/irisnet/core-sdk-go
modulepackage
0.2.0
Repository: https://github.com/irisnet/core-sdk-go.git
Documentation: pkg.go.dev

# README

Core SDK

Golang SDK for Tendermint & Cosmos-SDK Core Modules

install

Requirement

Go version above 1.16.4

Use Go Mod

replace (
    github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.2-alpha.regen.4
    github.com/tendermint/tendermint => github.com/bianjieai/tendermint v0.34.1-irita-210113
)

Init Client

The initialization SDK code is as follows:

    bech32AddressPrefix := types.AddrPrefixCfg{
        AccountAddr:   "iaa",
        ValidatorAddr: "iva",
        ConsensusAddr: "ica",
        AccountPub:    "iap",
        ValidatorPub:  "ivp",
        ConsensusPub:  "icp",
    }
    options := []types.Option{
        types.KeyDAOOption(store.NewMemory(nil)),
        types.TimeoutOption(10),
        types.TokenManagerOption(TokenManager{}),
        types.KeyManagerOption(crypto.NewKeyManager()),
        types.Bech32AddressPrefixOption(bech32AddressPrefix),
        types.BIP44PathOption(""),
    }
    cfg, err := types.NewClientConfig(nodeURI, grpcAddr, chainID, options...)
    if err != nil {
        panic(err)
    }
    
    s.Client = sdk.NewClient(cfg)

The NewClientConfig component mainly contains the parameters used in the SDK, the specific meaning is shown in the table below.

ItermTypeDescription
NodeURIstringThe RPC address of the IRIShub node connected to the SDK, for example: localhost: 26657
GRPCAddrstringThe GRPC address of the IRIShub node connected to the SDK, for example: localhost: 9090
NetworkenumIRIShub network type, value: Testnet, Mainnet
ChainIDstringChainID of IRIShub, for example: IRIShub
Gasuint64The maximum gas to be paid for the transaction, for example: 20000
FeeDecCoinsTransaction fees to be paid for transactions
KeyDAOKeyDAOPrivate key management interface, If the user does not provide it, the default LevelDB will be used
ModeenumTransaction broadcast mode, value: Sync, Async, Commit
StoreTypeenumPrivate key storage method, value: Keystore, PrivKey
Timeouttime. DurationTransaction timeout, for example: 5s
LevelstringLog output level, for example: info

If you want to use SDK to send a transfer transaction, the example is as follows:

There is more example of query and send tx

    coins, err := types.ParseDecCoins("10iris")
    to := "iaa1hp29kuh22vpjjlnctmyml5s75evsnsd8r4x0mm"
    baseTx := types.BaseTx{
        From:               s.Account().Name,
        Gas:                200000,
        Memo:               "TEST",
        Mode:               types.Commit,
        Password:          "password",
        SimulateAndExecute: false,
        GasAdjustment:      1.5,
    }
    
    res, err := s.Bank.Send(to, coins, baseTx)

# Packages

No description provided by the author
Package modules is to warpped the API provided by each module of IRITA.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Package types defines a custom wrapper for google.protobuf.Any which supports cached values as well as InterfaceRegistry which keeps track of types which can be used with Any for both security and introspection */.

# Functions

No description provided by the author
RegisterInterfaces registers the sdk message type.
RegisterLegacyAminoCodec registers the sdk message type.

# Structs

No description provided by the author