example

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: MIT Imports: 15 Imported by: 0

README

Example

CKB Go SDK examples

Introduction

The example.go provides some examples shows how to use this sdk to interact with CKB's RPC, transaction, and Nervos DAO(deposit and withdraw).

Transaction Examples

These examples show how to transfer CKB, in different situations.

  • SendCkbExample: sign and send CKB from single-sig address.
  • SendCkbByLightClientExample: similiar to SendCkbExample but interact with ckb-light-client
  • SendCkbFromMultisigAddressExample: sign and send CKB from multi-sig address with multiple private keys.
  • SendChainedTransactionExample: sign and send offchain transaction

SUDT Examples

SUDT (Simple User Defined Tokens) is a token specification on CKB. You can think SUDT is an analog of ERC20 on Ethereum.

Anyone can issue his own SUDT, or transfer a specific kind of SUDT if he has enough SUDT amount. SUDT smart contract should be used in type script in these transactions.

  • IssueSudtExample: shows how to issue SUDT
  • SendSudtExample: shows how to send issued SUDT

Nervos DAO Examples

Nervos DAO is a smart contract, with which users can interact the same way as any smart contracts on CKB. Nervos DAO has deposit and withdraw (phase1 and phase2).

  • Deposit: Users can send a transaction to deposit CKB into Nervos DAO at any time. CKB includes a special Nervos DAO type script in the genesis block.
  • Withdraw: Users can send a transaction to withdraw deposited CKB from Nervos DAO at any time (but a locking period will be applied to determine when exactly the tokens can be withdrawn).

Check Nervos DAO RFC for more details

  • DepositDaoExample: shows how to deposit DAO
  • WithdrawDaoExample: shows how to withdraw deposited CKB from Nervos DAO

OmniLock Examples

Omnilock is a new lock script designed for interoperability. Check https://blog.cryptape.com/omnilock-a-universal-lock-that-powers-interoperability-1 for more details

  • SendCkbOmnilockExample: similar to SendCkbExample, but use Omnilock to sign.
  • SendCkbMultisigOmnilockExample: similar to SendCkbFromMultisigAddressExample, but use Omnilock to sign.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClaimDaoExample

func ClaimDaoExample() error

func DepositDaoExample

func DepositDaoExample() error

func IssueSudtExample

func IssueSudtExample() error

func SendChainedTransactionExample added in v2.0.3

func SendChainedTransactionExample() error

func SendCkbByLightClientExample added in v2.0.3

func SendCkbByLightClientExample() error

func SendCkbExample

func SendCkbExample() error

func SendCkbFromMultisigAddressExample

func SendCkbFromMultisigAddressExample() error

func SendCkbMultisigOmnilockExample added in v2.0.3

func SendCkbMultisigOmnilockExample() error

func SendCkbOmnilockExample added in v2.0.3

func SendCkbOmnilockExample() error

func SendSudtExample

func SendSudtExample() error

func WithdrawDaoExample

func WithdrawDaoExample() error

Types

This section is empty.

Jump to

Keyboard shortcuts

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