antchain

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

README

antchain

蚂蚁联盟链 Go SDK

Documentation

Index

Constants

View Source
const (
	CHAIN_CALL_FOR_BIZ = "/api/contract/chainCallForBiz"
	CHAIN_CALL         = "/api/contract/chainCall"
	SHAKE_HAND         = "/api/contract/shakeHand"
)

Variables

This section is empty.

Functions

func ParseOutput

func ParseOutput(data string) (string, error)

ParseOutput 解析合约方法返回的output

Types

type ChainCallOption

type ChainCallOption func(params lib.X)

ChainCallOption 链调用选项

func WithParam

func WithParam(key string, value any) ChainCallOption

type Client

type Client interface {
	// CreateAccount 创建账户
	CreateAccount(ctx context.Context, account, kmsID string, gas int) (string, error)

	// Deposit 存证
	Deposit(ctx context.Context, content string, gas int) (string, error)

	// DeploySolidity 部署Solidity合约
	DeploySolidity(ctx context.Context, name, code string, gas int) (string, error)

	// AsyncCallSolidity 异步调用Solidity合约
	AsyncCallSolidity(ctx context.Context, contractName, methodSign, inputParams, outTypes string, gas int) (string, error)

	// QueryTransaction 查询交易
	QueryTransaction(ctx context.Context, hash string) (string, error)

	// QueryReceipt 查询交易回执
	QueryReceipt(ctx context.Context, hash string) (string, error)

	// QueryBlockHeader 查询块头
	QueryBlockHeader(ctx context.Context, blockNumber int64) (string, error)

	// QueryBlockBody 查询块体
	QueryBlockBody(ctx context.Context, blockNumber int64) (string, error)

	// QueryLastBlock 查询最新块高
	QueryLastBlock(ctx context.Context) (string, error)

	// QueryAccount 查询账户
	QueryAccount(ctx context.Context, account string) (string, error)
}

Client 发送请求使用的客户端

func NewClient

func NewClient(cfg *Config, options ...Option) Client

NewClient 生成蚂蚁联盟链客户端

type Config

type Config struct {
	BizID      string                 `json:"biz_id"`      // 链ID (a00e36c5)
	TenantID   string                 `json:"tenant_id"`   // 租户ID
	AccessID   string                 `json:"access_id"`   // AccessID
	AccessKey  *lib_crypto.PrivateKey `json:"access_key"`  // AccessKey
	Account    string                 `json:"account"`     // 链账户
	MyKmsKeyID string                 `json:"mykmskey_id"` // 托管标识
}

Config 客户端配置

type Identity

type Identity struct {
	Data string `json:"data"`
}

Identity 链账户对应的Identity

func GetIdentityByName

func GetIdentityByName(name string) *Identity

GetIdentityByName 根据链账户名称获取对应的Identity

type Option

type Option func(c *client)

Option 自定义设置项

func WithHttpCli

func WithHttpCli(httpCli *http.Client) Option

WithHttpCli 设置自定义 HTTP Client

func WithLogger

func WithLogger(fn func(ctx context.Context, data map[string]string)) Option

WithLogger 设置日志记录

type TokenID

type TokenID *big.Int

TokenID 链上资产(NFT)的唯一标识

func GetTokenID

func GetTokenID(token string) TokenID

GetTokenID 获取token(如:md5值)对应的tokenID(uint256)

Jump to

Keyboard shortcuts

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