standard

package
v1.0.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	Topic_Register    = "Register"
	Topic_SetResolver = "SetResolver"
	Topic_Bind        = "Bind"
	Topic_UnBind      = "UnBind"
	Topic_ReverseBind = "ReverseBind"
)
View Source
const (
	TopicTransfer = "transfer"
	TopicApprove  = "approve"
	TopicMint     = "mint"
	TopicBurn     = "burn"
)

Event top list

View Source
const (
	Topic_SetDidDocument    = "SetDidDocument"
	Topic_SetTrustRootList  = "SetTrustRootList"
	Topic_RevokeVc          = "RevokeVc"
	Topic_AddBlackList      = "AddBlackList"
	Topic_DeleteBlackList   = "DeleteBlackList"
	Topic_AddTrustIssuer    = "AddTrustIssuer"
	Topic_DeleteTrustIssuer = "DeleteTrustIssuer"
	Topic_Delegate          = "Delegate"
	Topic_RevokeDelegate    = "RevokeDelegate"
	Topic_SetVcTemplate     = "SetVcTemplate"
	Topic_VcIssueLog        = "VcIssueLog"
)
View Source
const (
	// ContractStandardNameCMBC ChainMaker - Contract Standard - Base Contract
	ContractStandardNameCMBC = "CMBC"
	// ContractStandardNameCMDFA ChainMaker - Contract Standard - Digital Fungible Assets
	ContractStandardNameCMDFA = "CMDFA"
	// ContractStandardNameCMNFA ChainMaker - Contract Standard - Digital Non-Fungible Assets
	ContractStandardNameCMNFA = "CMNFA"
	// ContractStandardNameCMID ChainMaker - Contract Standard - Identity
	ContractStandardNameCMID = "CMID"
	// ContractStandardNameCMEVI  ChainMaker - Contract Standard - Evidence
	ContractStandardNameCMEVI = "CMEVI"
	// ContractStandardNameCMDID ChainMaker - Contract Standard - Decentralized Identifier
	ContractStandardNameCMDID = "CMDID"
	// ContractStandardNameCMBCS ChainMaker - Contract Standard - Blockchain Name Service
	ContractStandardNameCMBNS = "CMBNS"
	// ContractStandardNameCMBNSResolver ChainMaker - Contract Standard - Blockchain Name Service Resolver
	ContractStandardNameCMBNSResolver = "CMBNSResolver"

	TrueString  = "true"
	FalseString = "false"
)
View Source
const (
	Topic_Evidence = "Evidence"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountTokens

type AccountTokens struct {
	Account string   `json:"account"`
	Tokens  []string `json:"tokens"`
}

type CMBC

type CMBC interface {
	// Standards  获取当前合约支持的标准协议列表
	// @return []string json格式字符串数组
	Standards() []string

	// SupportStandard  获取当前合约是否支持某合约标准协议
	// @return bool 存在:true,"true";不存在:false,"false"
	SupportStandard(standardName string) bool
}

CMBC 长安链基础合约go接口 https://git.chainmaker.org.cn/contracts/standard/-/blob/master/draft/CM-CS-221221-BC.md

type CMBNS added in v1.0.4

type CMBNS interface {
	//CMNFA 嵌入的非同质化通证接口
	CMNFA
	// Domain 获取根域名
	Domain() string
	// Register 注册域名
	Register(domain string, owner string, metadata string, expirationTime int) error
	// Renew 续期域名
	Renew(domain string, expirationTime int) error
	// GetDomainInfo 获取域名信息
	GetDomainInfo(domain string) (*DomainInfo, error)
	// GetDomainList 获取域名列表
	GetDomainList(domainSearch string, owner string, start int, count int) ([]*DomainInfo, error)
	// EmitRegisterEvent 发送注册域名事件
	EmitRegisterEvent(domain string, owner string, metadata string, expirationTime int)
	// SetResolver 设置域名解析器
	SetResolver(domain string, resolver string) error
	// ResetResolver 重置域名解析器
	ResetResolver(domain string, resourceType string) error
	// EmitSetResolverEvent 发送设置域名解析器事件
	EmitSetResolverEvent(domain string, resolver string)
	// EmitReverseBindEvent 发送反向绑定事件
	EmitReverseBindEvent(value string, domain string, resourceType string)
	//CMBNSResolver 嵌入的接口
	CMBNSResolver
}

CMBNS 长安链区块链名称服务go接口,因为CMBNS合约也会支持CMNFA标准,所以不需要再单独定义Owner查询、Transfer转移域名等接口

type CMBNSOption added in v1.0.4

type CMBNSOption interface {
	// AddBlackList 添加黑名单
	AddBlackList(domains []string) error
	// DeleteBlackList 删除黑名单
	DeleteBlackList(domains []string) error
	// GetBlackList 获取黑名单
	GetBlackList(domainSearch string, start int, count int) ([]string, error)
	// EmitAddBlackListEvent 发送添加黑名单事件
	EmitAddBlackListEvent(domains []string)
	// EmitDeleteBlackListEvent 发送删除黑名单事件
	EmitDeleteBlackListEvent(domains []string)
}

CMBNSOption 可选的CMBNS接口

type CMBNSResolver added in v1.0.4

type CMBNSResolver interface {
	// Bind 绑定域名
	Bind(domain string, resolveValue string, resourceType string) error
	// Unbind 解绑域名
	Unbind(domain string, resourceType string) error
	// Resolve 解析域名
	Resolve(domain string, resourceType string) (string, error)
	// ReverseResolve 反向解析地址
	ReverseResolve(address string, resourceType string) (string, error)
	// GetBindList 按前缀匹配的方式搜索绑定列表
	// @param domainSearch 域名搜索关键字
	GetBindList(domainSearch string, start int, count int) ([]*DomainInfo, error)
	// EmitBindEvent 发送域名绑定事件
	EmitBindEvent(domain string, resolveValue string, resourceType string)
	// EmitUnBindEvent 发送域名解绑
	EmitUnBindEvent(domain string, resourceType string)
}

CMBNSResolver 解析器合约应该满足的标准,只有满足这些接口的合约才能被设置为解析器

type CMDFA

type CMDFA interface {

	// Name 查询Token的完整名称
	// @return name
	// @return err
	Name() (name string, err error)

	// Symbol 查询Token的简写符号
	// @return symbol
	// @return err
	Symbol() (symbol string, err error)

	// Decimals 查询Token支持的小数位数
	// @return decimals 返回支持的小数位数
	Decimals() (decimals uint8, err error)

	// TotalSupply 查询Token的发行总量
	// @return totalSupply 返回发行的Token总量
	TotalSupply() (totalSupply *safemath.SafeUint256, err error)

	// BalanceOf 查询账户的Token余额
	// @param account 指定要查询余额的账户
	// @return amount 返回指定账户的余额
	BalanceOf(account string) (amount *safemath.SafeUint256, err error)

	// Transfer 转账
	// @param to 收款账户
	// @param amount 转账金额
	// @return success 转账成功或失败
	// @return err 转账失败则返回Status:ERROR,Message具体错误
	Transfer(to string, amount *safemath.SafeUint256) error

	// TransferFrom 转账from账户下的指定amount金额给to账户
	// @param from 转出账户
	// @param to 转入账户
	// @param amount 转账金额
	// @return success 转账成功或失败
	// @return err 转账失败则返回Status:ERROR,Message具体错误
	TransferFrom(from string, to string, amount *safemath.SafeUint256) error

	// Approve 当前调用者授权指定的spender账户可以动用自己名下的amount金额给使用
	// @param spender 被授权账户
	// @param amount 授权使用的金额
	// @return success 授权成功或失败
	// @return error 授权失败则返回Status:ERROR,Message具体错误
	Approve(spender string, amount *safemath.SafeUint256) error

	// Allowance 查询owner授权多少额度给spender
	// @param owner 授权人账户
	// @param spender 被授权使用的账户
	// @return amount 返回授权金额
	Allowance(owner string, spender string) (amount *safemath.SafeUint256, err error)

	// EmitTransferEvent 发送转账事件
	// @param spender 转出账户
	// @param to 转入账户
	// @param amount 转账金额
	EmitTransferEvent(spender, to string, amount *safemath.SafeUint256)

	// EmitApproveEvent 发送授权事件
	// @param owner 授权人账户
	// @param spender 被授权使用的账户
	// @param amount 转账金额
	EmitApproveEvent(owner, spender string, amount *safemath.SafeUint256)
}

CMDFA 长安链同质化资产合约go接口 https://git.chainmaker.org.cn/contracts/standard/-/blob/master/draft/CM-CS-221221-DFA.md

type CMDFAOption

type CMDFAOption interface {
	// Mint 铸造发行新Token
	// @param account 发行到指定账户
	// @param amount 铸造发行新Token的数量
	// @return success 发行成功或失败
	// @return err 发行失败则返回Status:ERROR,Message具体错误
	Mint(account string, amount *safemath.SafeUint256) error

	// Burn 销毁当前用户名下指定数量的Token
	// @param amount 要销毁的Token数量
	// @return success 销毁成功或失败
	// @return err 销毁失败则返回Status:ERROR,Message具体错误
	Burn(amount *safemath.SafeUint256) error

	// BurnFrom 从spender账户名下销毁指定amount数量的Token
	// @param spender 被销毁Token的所属账户
	// @param amount 要销毁的数量
	// @return success 销毁成功或失败
	// @return err 销毁失败则返回Status:ERROR,Message具体错误
	BurnFrom(spender string, amount *safemath.SafeUint256) error

	// EmitMintEvent 触发铸造事件
	// @param account
	// @param amount
	EmitMintEvent(account string, amount *safemath.SafeUint256)

	// EmitBurnEvent 触发销毁事件
	// @param spender
	// @param amount
	EmitBurnEvent(spender string, amount *safemath.SafeUint256)

	// BatchTransfer 批量转账
	// @param to 收款账户
	// @param amount 转账金额,可以是1个表示每个to的金额相同,或多个(与to的数量相同)
	BatchTransfer(to []string, amount []*safemath.SafeUint256) error

	// Metadata 查询Token的元数据,其中包含Token的名称、符号、小数位数、LogoUrl、描述等信息
	Metadata() (metadata []byte, err error)
}

CMDFAOption 可选的CMDFA接口

type CMDID added in v1.0.4

type CMDID interface {
	// DidMethod 获取DID方法
	DidMethod() string
	// IsValidDid 判断DID URL是否合法
	IsValidDid(did string) (bool, error)
	// AddDidDocument 添加DID文档
	AddDidDocument(didDocument string) error
	// GetDidDocument 根据DID URL获取DID文档
	GetDidDocument(did string) (string, error)

	// GetDidByPubkey 根据公钥获取DID URL
	GetDidByPubkey(pk string) (string, error)
	// GetDidByAddress 根据地址获取DID URL
	GetDidByAddress(address string) (string, error)
	// VerifyVc 验证vc
	VerifyVc(vcJson string) (bool, error)
	// VerifyVp 验证vp
	VerifyVp(vpJson string) (bool, error)
	// EmitSetDidDocumentEvent 发送添加DID文档事件
	EmitSetDidDocumentEvent(did string, didDocument string)

	// RevokeVc 撤销vc,撤销后的vc vp不能再被验证
	RevokeVc(vcID string) error
	// GetRevokedVcList 获取撤销vc列表
	GetRevokedVcList(vcIDSearch string, start int, count int) ([]string, error)
	// EmitRevokeVcEvent 发送撤销vc事件
	EmitRevokeVcEvent(vcID string)
}

CMDID 长安链DID https://git.chainmaker.org.cn/contracts/standard/-/blob/master/draft/CM-CS-221221-Identity.md

type CMDIDOption added in v1.0.4

type CMDIDOption interface {
	// UpdateDidDocument 更新DID文档
	UpdateDidDocument(didDocument string) error

	// AddBlackList 添加黑名单
	AddBlackList(dids []string) error
	// DeleteBlackList 删除黑名单
	DeleteBlackList(dids []string) error
	// GetBlackList 获取黑名单
	GetBlackList(didSearch string, start int, count int) ([]string, error)
	// EmitAddBlackListEvent 发送添加黑名单事件
	EmitAddBlackListEvent(dids []string)
	// EmitDeleteBlackListEvent 发送删除黑名单事件
	EmitDeleteBlackListEvent(dids []string)

	// SetTrustRootList 设置信任根列表
	SetTrustRootList(dids []string) error
	// GetTrustRootList 获取信任根列表
	GetTrustRootList() (dids []string, err error)
	// EmitSetTrustRootListEvent 发送设置信任根列表事件
	EmitSetTrustRootListEvent(dids []string)

	// AddTrustIssuer 添加信任的发行者
	AddTrustIssuer(dids []string) error
	// DeleteTrustIssuer 删除信任的发行者
	DeleteTrustIssuer(dids []string) error
	// GetTrustIssuer 获取信任的发行者
	GetTrustIssuer(didSearch string, start int, count int) ([]string, error)
	// EmitAddTrustIssuerEvent 发送添加信任的发行者事件
	EmitAddTrustIssuerEvent(dids []string)
	// EmitDeleteTrustIssuerEvent 发送删除信任的发行者事件
	EmitDeleteTrustIssuerEvent(dids []string)

	// Delegate 给delegateeDid授权delegatorDid的资源代理权限,在有效期内,delegateeDid可以代理delegatorDid对resource的action操作
	// @param delegateeDid 被授权者DID
	// @param resource 资源,一般是VcID
	// @param action 操作,一般是"issue"或"verify"
	// @param expiration 有效期,unix时间戳,0表示永久
	Delegate(delegateeDid string, resource string, action string, expiration int64) error
	// EmitDelegateEvent 发送授权事件
	EmitDelegateEvent(delegatorDid string, delegateeDid string, resource string, action string, start int64, expiration int64)
	// RevokeDelegate 撤销授权
	RevokeDelegate(delegateeDid string, resource string, action string) error
	// EmitRevokeDelegateEvent 发送撤销授权事件
	EmitRevokeDelegateEvent(delegatorDid string, delegateeDid string, resource string, action string)
	// GetDelegateList 查询授权列表
	GetDelegateList(delegatorDid, delegateeDid string, resource string, action string, start int, count int) ([]*DelegateInfo, error)

	// SetVcTemplate 设置vc模板
	SetVcTemplate(id string, name string, vcType string, version string, template string) error
	// GetVcTemplate 获取vc模板
	GetVcTemplate(id, version string) (*VcTemplate, error)
	// GetVcTemplateList 获取vc模板列表
	GetVcTemplateList(nameSearch string, start int, count int) ([]*VcTemplate, error)
	// EmitSetVcTemplateEvent 发送设置vc模板事件
	EmitSetVcTemplateEvent(templateID string, templateName string, vcType string, version string, vcTemplate string)

	// VcIssueLog 记录vc发行日志
	// @param issuer 必填,发行者DID
	// @param did 必填,vc持有者DID
	// @param templateID 选填,vc模板ID
	// @param vcID 必填,vcID或者vc hash
	VcIssueLog(issuer string, did string, templateID string, vcID string) error
	// GetVcIssueLogs 获取vc发行日志
	GetVcIssueLogs(issuer string, did string, templateID string, start int, count int) ([]*VcIssueLog, error)
	// GetVcIssuers 根据持证人DID获取vc发行者DID列表
	GetVcIssuers(did string) (issuerDid []string, err error)
	// EmitVcIssueLogEvent 发送vc发行日志事件
	EmitVcIssueLogEvent(issuer string, did string, templateID string, vcID string)
}

type CMEVI

type CMEVI interface {
	// Evidence 存证
	// @param id 必填,流水号
	// @param hash 必填,上链哈希值
	// @param metadata 可选,其他信息;比如:哈希的类型(文字,文件)、文字描述的json格式字符串,具体参考下方 Metadata 对象。
	// @return error 返回错误信息
	Evidence(id string, hash string, metadata string) error

	// ExistsOfHash 哈希是否存在
	// @param hash 必填,上链的哈希值
	// @return exist 存在:true,"true";不存在:false,"false"
	// @return err 错误信息
	ExistsOfHash(hash string) (exist bool, err error)

	// ExistsOfId ID是否存在
	// @param id 必填,上链的ID值
	// @return exist 存在:true,"true";不存在:false,"false"
	// @return err 错误信息
	ExistsOfId(id string) (exist bool, err error)

	// FindByHash 根据哈希查找
	// @param hash 必填,上链哈希值
	// @return evidence 上链时传入的evidence信息
	// @return err 返回错误信息
	FindByHash(hash string) (evidence *Evidence, err error)

	// FindById 根据id查找
	// @param id 必填,流水号
	// @return evidence 上链时传入的evidence信息
	// @return err 返回错误信息
	FindById(id string) (evidence *Evidence, err error)

	// EmitEvidenceEvent 发送存证事件
	EmitEvidenceEvent(id string, hash string, metadata string) error
}

CMEVI 长安链存证合约go接口 https://git.chainmaker.org.cn/contracts/standard/-/blob/master/draft/CM-CS-221221-Evidence.md

type CMEVIOption

type CMEVIOption interface {

	// EvidenceBatch 批量存证
	// @param evidences 必填,存证信息
	// @return error 返回错误信息
	EvidenceBatch(evidences []Evidence) error

	// UpdateEvidence 根据ID更新存证哈希和metadata
	// @param id 必填,已经在链上存证的流水号。 如果是新流水号返回错误信息不存在
	// @param hash 必填,上链哈希值。必须与链上已经存储的hash不同
	// @param metadata 可选,其他信息;具体参考下方 Metadata 对象。
	// @return error 返回错误信息
	// @desc 该方法由长安链社区志愿者@sunhuiyuan提供建议,感谢参与
	UpdateEvidence(id string, hash string, metadata string) error

	// FindHisById 根据ID流水号查找存证历史(可以使用go合约接口:sdk.Instance.NewHistoryKvIterForKey或NewIterator实现)
	// @param id 必填,流水号
	// @return string 上链时传入的evidence信息的各个版本JSON数组对象。如果之前上链没有调用过updateEvidence、效果等同于findById,数组大小为1;
	//                如果之前上链调用过updateEvidence,则结果数组长度>1。
	// @return error 返回错误信息
	// @desc 该方法由长安链社区志愿者@sunhuiyuan提供建议,感谢参与
	FindHisById(id string) (evidence Evidence, err error)
}

type CMID

type CMID interface {
	// Identities 获取该合约支持的所有认证类型
	// @return metas, 所有的认证类型编号和认证类型描述
	Identities() (metas []IdentityMeta)

	// SetIdentity 为地址设置认证类型,管理员可调用
	// @param address 必填,公钥/证书的地址。一个地址仅能绑定一个公钥和认证类型编号,重复输入则覆盖。
	// @param pkPem 选填,pem格式公钥,可用于验签
	// @param level 必填,认证类型编号
	// @param metadata 选填,其他信息,json格式字符串,比如:地址类型,上链人身份、组织信息,上链可信时间,上链批次等等
	// @return error 返回错误信息
	// @event topic: setIdentity(address, level, pkPem)
	SetIdentity(address, pkPem string, level int, metadata string) error

	// IdentityOf 获取认证信息
	// @param address 地址
	// @return int 返回当前认证类型编号
	// @return identity 认证信息
	// @return err 返回错误信息
	IdentityOf(address string) (identity Identity, err error)

	// LevelOf 获取认证编号
	// @param address 地址
	// @return level 返回当前认证类型编号
	// @return err 返回错误信息
	LevelOf(address string) (level int, err error)

	// EmitSetIdentityEvent 发送设置认证类型事件
	// @param address 地址
	// @param pkPem pem格式公钥
	// @param level 认证类型编号
	EmitSetIdentityEvent(address, pkPem string, level int)
}

CMID 长安链身份认证go接口 https://git.chainmaker.org.cn/contracts/standard/-/blob/master/draft/CM-CS-221221-Identity.md

type CMIDOption

type CMIDOption interface {
	// PkPemOf 获取公钥
	// @param address 地址
	// @return string 返回当前地址绑定的公钥
	// @return error 返回错误信息
	PkPemOf(address string) (string, error)

	// SetIdentityBatch 设置多个认证类型,管理员可调用
	// @param identities, 入参json格式字符串
	// @event topic: setIdentity(address, level, pkPem)
	SetIdentityBatch(identities []Identity) error

	// AlterAdminAddress 修改管理员,管理员可调用
	// @param adminAddresses 管理员地址,可为空,默认为创建人地址。入参为以逗号分隔的地址字符串"addr1,addr2"
	// @return error 返回错误信息
	// @event topic: alterAdminAddress(adminAddresses)
	AlterAdminAddress(adminAddresses string) error
}

type CMNFA

type CMNFA interface {
	// Mint a token, Obligatory.
	// @param to, the owner address of the token. Obligatory.
	// @param tokenId, the id of the token. Obligatory.
	// @param categoryName, the name of the category. If categoryName is empty, the token's category
	// will be the default category. Optional.
	// @param metadata, the metadata of the token. Optional.
	// @return error, the error msg if some error occur.
	// @event, topic: 'mint'; data: to, tokenId, categoryName, metadata
	Mint(to, tokenId, categoryName string, metadata []byte) error

	// MintBatch mint nft tokens batch. Obligatory.
	// @param tokens, the tokens to mint. Obligatory.
	// @return error, the error msg if some error occur.
	// @event, topic: 'mintBatch'; data: tokens
	MintBatch(tokens []NFA) error

	// SetApproval approve or cancel approve token to 'to' account. Obligatory.
	// @param owner, the owner of token. Obligatory.
	// @param to, destination approve to. Obligatory.
	// @param tokenId, the token id. Obligatory.
	// @param isApproval, to approve or to cancel approve
	// @return error, the error msg if some error occur.
	// @event, topic: 'setApproval'; data: to, tokenId, isApproval
	SetApproval(owner, to, tokenId string, isApproval bool) error

	// SetApprovalForAll approve or cancel approve all token to 'to' account. Obligatory.
	// @param owner, the owner of token. Obligatory.
	// @param to, destination address approve to. Obligatory.
	// @isApprove, true means approve and false means cancel approve. Obligatory.
	// @return error, the error msg if some error occur.
	// @event, topic: 'setApprovalForAll'; data: to, isApproval
	SetApprovalForAll(owner, to string, isApproval bool) error

	// TransferFrom transfer single token after approve. Obligatory.
	// @param from, owner account of token. Obligatory.
	// @param to, destination account transferred to. Obligatory.
	// @param tokenId, the token being transferred. Obligatory.
	// @return error, the error msg if some error occur.
	// @event, topic: 'transferFrom'; data: from, to, tokenId
	TransferFrom(from, to, tokenId string) error

	// TransferFromBatch transfer tokens after approve. Obligatory.
	// @param from, owner account of token. Obligatory.
	// @param to, destination account transferred to. Obligatory.
	// @param tokenIds, the tokens being transferred. Obligatory.
	// @return error, the error msg if some error occur.
	// @event, topic: 'transferFromBatch'; data: from, to, tokenIds
	TransferFromBatch(from, to string, tokenIds []string) error

	// OwnerOf get the owner of a token. Obligatory.
	// @param tokenId, the token which will be queried. Obligatory.
	// @return account, the token's account.
	// @return err, the error msg if some error occur.
	OwnerOf(tokenId string) (account string, err error)

	// TokenURI get the URI of the token. a token's uri consists of CategoryURI and tokenId. Obligatory.
	// @param tokenId, tokenId be queried. Obligatory.
	// @return uri, the uri of the token.
	// @return err, the error msg if some error occur.
	TokenURI(tokenId string) (uri string, err error)

	// EmitMintEvent emit mint event
	// @param to  destination account transferred to
	// @param tokenId
	// @param categoryName category name
	// @param metadata other info
	EmitMintEvent(to, tokenId, categoryName, metadata string)

	// EmitSetApprovalEvent emit set approval event
	// @param owner  account of token.
	// @param to  destination account transferred to
	// @param tokenId
	// @param isApproval true means approve and false means cancel approve.
	EmitSetApprovalEvent(owner, to, tokenId string, isApproval bool)

	// EmitSetApprovalForAllEvent emit set approval for all event
	// @param owner  account of token.
	// @param to  destination account transferred to
	// @param isApproval true means approve and false means cancel approve.
	EmitSetApprovalForAllEvent(owner, to string, isApproval bool)

	// EmitTransferFromEvent emit transfer from event
	// @param from owner  account of token.
	// @param to  destination account transferred to
	// @param tokenId
	EmitTransferFromEvent(from, to, tokenId string)
}

CMNFA Chainmaker NFA standard interface https://git.chainmaker.org.cn/contracts/standard/-/blob/master/draft/CM-CS-221221-NFA.md

type CMNFAOption

type CMNFAOption interface {
	// SetApprovalByCategory approve or cancel approve tokens of category to 'to' account. Optional.
	// @param owner, the owner of token. Obligatory.
	// @param to, destination address approve to. Obligatory.
	// @categoryName, the category of tokens. Obligatory.
	// @isApproval, to approve or to cancel approve. Obligatory.
	// @return error, the error msg if some error occur.
	// @event, topic: 'setApprovalByCategory'; data: to, categoryName, isApproval
	SetApprovalByCategory(owner, to, categoryName string, isApproval bool) error

	// CreateOrSetCategory create a category of tokens. Optional.
	// @param categoryName, the category name. Obligatory.
	// @param categoryURI, the category uri. Obligatory.
	// @return error, the error msg if some error occur.
	// @event, topic: 'createOrSetCategory'; data: category
	CreateOrSetCategory(category *Category) error

	// Burn burn token
	// @param tokenId, tokenId
	Burn(tokenId string) error

	// GetCategoryByName get specific category by name. Optional.
	// @param categoryName, the name of the category. Obligatory.
	// @return category, the category returned.
	// @return err, the error msg if some error occur.
	GetCategoryByName(categoryName string) (category *Category, err error)

	// GetCategoryByTokenId get a specific category by tokenId. Optional.
	// @param tokenId, the names of category to be queried. Obligatory.
	// @return category, the result queried.
	// @return err, the error msg if some error occur.
	GetCategoryByTokenId(tokenId string) (category *Category, err error)

	// TotalSupply get total token supply of this contract. Optional.
	// @return totalSupply, the total token supply value returned.
	// @return err, the error msg if some error occur.
	TotalSupply() (totalSupply *safemath.SafeUint256, err error)

	// TotalSupplyOfCategory get total token supply of the category. Optional.
	// @param category, the category of tokens. Obligatory.
	// @return totalSupply, the total token supply value returned.
	// @return err, the error msg if some error occur.
	TotalSupplyOfCategory(category string) (totalSupply *safemath.SafeUint256, err error)

	// BalanceOf get total token number of the account. Optional
	// @param account, the account which will be queried. Obligatory.
	// @return balance, the token number of the account.
	// @return err, the error msg if some error occur.
	BalanceOf(account string) (balance *safemath.SafeUint256, err error)

	// AccountTokens get the token list of the account. Optional
	// @param account, the account which will be queried. Obligatory.
	// @return tokenId, the list of tokenId.
	// @return err, the error msg if some error occur.
	AccountTokens(account string) (tokenId []string, err error)

	// TokenMetadata get the metadata of a token. Optional.
	// @param tokenId, tokenId which will be queried.
	// @return metadata, the metadata of the token.
	// @return err, the error msg if some error occur.
	TokenMetadata(tokenId string) (metadata []byte, err error)

	// EmitBurnEvent emit burn event
	// @param tokenId
	EmitBurnEvent(tokenId string)

	// EmitCreateOrSetCategoryEvent emit CreateOrSetCategory event
	// @param categoryName
	// @param categoryURI
	EmitCreateOrSetCategoryEvent(categoryName, categoryURI string)

	// EmitSetApprovalByCategoryEvent emit set approval by category event
	// @param owner  account of token.
	// @param to  destination account transferred to
	// @param categoryName
	// @param isApproval true means approve and false means cancel approve.
	EmitSetApprovalByCategoryEvent(owner, to, categoryName string, isApproval bool)
}

type Category

type Category struct {
	// CategoryName, the name of the category
	CategoryName string `json:"categoryName"`
	// CategoryURI, the uri of the category
	CategoryURI string `json:"categoryURI"`
}

Category the tokens' category info

type DelegateInfo added in v1.0.4

type DelegateInfo struct {
	// DelegatorDid 授权者DID
	DelegatorDid string `json:"delegatorDid"`
	// DelegateeDid 被授权者DID
	DelegateeDid string `json:"delegateeDid"`
	// Resource 资源,一般是VcID
	Resource string `json:"resource"`
	// Action 操作,一般是"issue"或"verify"
	Action string `json:"action"`
	// StartTime 授权开始时间
	StartTime int64 `json:"startTime"`
	// Expiration 授权结束时间
	Expiration int64 `json:"expiration"`
}

DelegateInfo 授权信息

type DomainInfo added in v1.0.4

type DomainInfo struct {
	// Domain 域名
	Domain string `json:"domain"`
	// ResolveValue 解析值
	ResolveValue string `json:"resolveValue"`
	// 绑定的类型
	ResourceType string `json:"resourceType"`
	// Owner 所有者
	Owner string `json:"owner"`
	// ExpirationTime 过期时间
	ExpirationTime int `json:"expirationTime"`
	// Resolver 解析器合约地址
	Resolver string `json:"resolver"`
	// Status 域名状态,正常,过期,禁用
	Status string `json:"status"`
	// Metadata 元数据
	Metadata string `json:"metadata"`
}

DomainInfo 域名信息

type Evidence

type Evidence struct {
	// Id 业务流水号
	Id string `json:"id"`
	// Hash 哈希值
	Hash string `json:"hash"`
	// TxId 存证时交易ID
	TxId string `json:"txId"`
	// BlockHeight 存证时区块高度
	BlockHeight int `json:"blockHeight"`
	// Timestamp 存证时区块时间
	Timestamp string `json:"timestamp"`
	// Metadata 可选,其他信息;具体参考下方 Metadata 对象。
	Metadata string `json:"metadata"`
}

Evidence 存证结构体

type Identity

type Identity struct {
	// Address 公钥地址
	Address string `json:"address"`
	// PkPem 公钥详情
	PkPem string `json:"pkPem"`
	// Level 认证类型编号
	Level int `json:"level"`
	// Metadata 其他,json格式字符串,可包含地址类型,上链人身份、组织信息,上链可信时间,上链批次等等
	Metadata string `json:"metadata"`
}

Identity 认证入参

type IdentityMeta

type IdentityMeta struct {
	// Level 认证类型编号
	Level int `json:"level"`
	// Description 认证类型描述
	Description string `json:"description"`
}

IdentityMeta 认证类型基础信息

type IdentityMetadata added in v1.0.2

type IdentityMetadata struct {
	// AddressType 地址类型:0-chainmaker, 1-zxl, 2-ethereum,长安链默认是2
	AddressType string `json:"addressType"`
	// OrgId 组织ID
	OrgId string `json:"orgId"`
	// Role 上链人身份角色
	Role string `json:"role"`
	// Timestamp 可信存证时间
	Timestamp string `json:"timestamp"`
	// ProveTimestamp 可信存证时间证明
	ProveTimestamp string `json:"proveTimestamp"`
	// BatchId 批次ID
	BatchId string `json:"batchId"`
}

IdentityMetadata 可选信息建议字段,若包含以下相关信息,建议采用以下字段

type Metadata

type Metadata struct {
	// HashType 哈希的类型,文字、文件、视频、音频等
	HashType string `json:"hashType"`
	// HashAlgorithm 哈希算法,sha256、sm3等
	HashAlgorithm string `json:"hashAlgorithm"`
	// Username 存证人,用于标注存证的身份
	Username string `json:"username"`
	// Timestamp 可信存证时间
	Timestamp string `json:"timestamp"`
	// ProveTimestamp 可信存证时间证明
	ProveTimestamp string `json:"proveTimestamp"`
	// 存证内容
	Content string `json:"content"`
}

Metadata 可选信息建议字段,若包含以下相关信息存证,请采用以下字段

type NFA

type NFA struct {
	// TokenId, the id of the token
	TokenId string `json:"tokenId"`
	// CategoryName, the name of the category
	CategoryName string `json:"categoryName"`
	// To, the address which the token minted to
	To string `json:"to"`
	// Metadata, the metadata of the token
	Metadata []byte `json:"metadata"`
}

NFA a Digital Non-Fungible Assets

type VcIssueLog added in v1.0.4

type VcIssueLog struct {
	// Issuer 发行者DID
	Issuer string `json:"issuer"`
	// Did vc持有者DID
	Did string `json:"did"`
	// TemplateId vc模板ID
	TemplateId string `json:"templateID"`
	// VcID vcID或者vc hash
	VcID string `json:"vcID"`
	// IssueTime 发行上链时间
	IssueTime int64 `json:"issueTime"`
}

VcIssueLog 记录vc发行日志

type VcTemplate added in v1.0.4

type VcTemplate struct {
	// Id 模板ID
	Id string `json:"id"`
	// Name 模板名称
	Name string `json:"name"`
	// Version 模板版本
	Version string `json:"version"`
	// VcType vc类型
	VcType string `json:"vcType"`
	// Template 模板内容
	Template string `json:"template"`
}

VcTemplate vc模板

Jump to

Keyboard shortcuts

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