vm

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// 合约相关配置
	MaxContractSize  uint64 // 最大合约大小
	WASIContractsDir string // WASI合约存储目录
	CodeManagerDir   string // 代码管理器存储目录
}

Config 引擎配置

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine 合约引擎,负责合约的部署和执行

func NewEngine

func NewEngine(config *Config) (*Engine, error)

NewEngine 创建新的合约引擎

func (*Engine) Close

func (e *Engine) Close() error

Close 关闭引擎

func (*Engine) DeleteContract

func (e *Engine) DeleteContract(contractAddr core.Address)

func (*Engine) DeployContract

func (e *Engine) DeployContract(code []byte) (core.Address, error)

DeployContract 部署合约

func (*Engine) DeployContractWithAddress

func (e *Engine) DeployContractWithAddress(code []byte, contractAddr core.Address) error

DeployContract 部署合约

func (*Engine) Execute

func (e *Engine) Execute(contractAddr core.Address, function string, args []byte) (interface{}, error)

ExecuteContract 执行合约函数带原始参数,参数是json.marshal(map[string]any)

func (*Engine) ExecuteContract

func (e *Engine) ExecuteContract(contractAddr core.Address, function string, args ...interface{}) (interface{}, error)

ExecuteContract 执行合约函数

func (*Engine) WithContext

func (e *Engine) WithContext(ctx types.BlockchainContext) *Engine

Jump to

Keyboard shortcuts

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