Documentation
¶
Overview ¶
Package core 定义了智能合约与VM系统交互所需的核心接口 合约开发者只需了解并使用此文件中的接口即可编写智能合约
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ZeroAddress = Address{}
View Source
var ZeroHash = Hash{}
View Source
var ZeroObjectID = ObjectID{}
Functions ¶
Types ¶
type Context ¶
type Context interface {
// 区块链信息相关
BlockHeight() uint64 // 获取当前区块高度
BlockTime() int64 // 获取当前区块时间戳
ContractAddress() Address // 获取当前合约地址
// 账户操作相关
Sender() Address // 获取交易发送者或调用合约
Balance(addr Address) uint64 // 获取账户余额
Transfer(to Address, amount uint64) error // 转账操作
// 对象存储相关 - 基础状态操作使用panic而非返回error
CreateObject() Object // 创建新对象,失败时panic
GetObject(id ObjectID) (Object, error) // 获取指定对象,可能返回error
GetObjectWithOwner(owner Address) (Object, error) // 按所有者获取对象,可能返回error
DeleteObject(id ObjectID) // 删除对象,失败时panic
// 跨合约调用
Call(contract Address, function string, args ...any) ([]byte, error)
// 日志与事件
Log(eventName string, keyValues ...interface{}) // 记录事件
}
Context 是合约与区块链环境交互的主要接口
Click to show internal directories.
Click to hide internal directories.