runtime

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2020 License: LGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package runtime provides a basic execution model for executing EVM code.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call

func Call(address common.Address, input []byte, cfg *Config) ([]byte, error)

Call executes the code given by the contract's address. It will return the EVM's return value or an error if it failed.

Call, unlike Execute, requires a config and also requires the am field to be set.

func Create

func Create(input []byte, cfg *Config) ([]byte, common.Address, uint64, error)

Create executes the code using the EVM create method

func Execute

func Execute(code, input []byte, cfg *Config) ([]byte, error)

Execute executes the code using the input as call data during the execution. It returns the EVM's return value, the new state and an error if it failed.

Executes sets up a in memory, temporarily, environment for the execution of the given code. It makes sure that it's restored to it's original state afterwards.

Example
package main

import (
	"fmt"

	"github.com/LemoFoundationLtd/lemochain-core/chain/vm/runtime"
	"github.com/LemoFoundationLtd/lemochain-core/common"
)

func main() {
	ret, err := runtime.Execute(common.FromHex("6060604052600a8060106000396000f360606040526008565b00"), nil, nil)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(ret)
}
Output:

[96 96 96 64 82 96 8 86 91 0]

func NewEnv

func NewEnv(cfg *Config) *vm.EVM

Types

type Config

type Config struct {
	Origin       common.Address
	MinerAddress common.Address
	BlockHeight  uint32
	Time         uint32
	GasLimit     uint64
	GasPrice     *big.Int
	Value        *big.Int
	Debug        bool
	EVMConfig    vm.Config

	AccountManager *account.Manager
	GetHashFn      func(n uint64) common.Hash
}

Config is a basic type specifying certain configuration flags for running the EVM.

Jump to

Keyboard shortcuts

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