vm

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2025 License: MIT Imports: 12 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 {
	// Contract related configuration
	MaxContractSize  uint64         // Maximum contract size
	WASIContractsDir string         // WASI contract storage directory
	CodeManagerDir   string         // Code manager storage directory
	ContextType      string         // Blockchain context type
	ContextParams    map[string]any // Blockchain context parameters
}

Config represents engine configuration

type Engine

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

Engine is responsible for contract deployment and execution

func NewEngine

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

NewEngine creates a new contract engine

func (*Engine) Close

func (e *Engine) Close() error

Close closes the engine

func (*Engine) DeleteContract

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

func (*Engine) DeployContract

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

DeployContract deploys a contract

func (*Engine) DeployContractWithAddress

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

DeployContractWithAddress deploys a contract with specified address

func (*Engine) Execute

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

ExecuteContract executes a contract function with raw parameters, parameters are json.marshal(map[string]any)

func (*Engine) ExecuteContract

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

ExecuteContract executes a contract function

func (*Engine) GetContext added in v0.1.2

func (e *Engine) GetContext() types.BlockchainContext

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