runtime

package
v0.0.0-...-17caa52 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call

func Call(address ethcomm.Address, input []byte, cfg *Config) ([]byte, uint64, 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 State field to be set.

func CanTransfer

func CanTransfer(db evm.StateDB, addr common.Address, amount *big.Int) bool

CanTransfer checks whether there are enough funds in the address' account to make a transfer. This does not take the necessary gas in to account to make the transfer valid.

func CompileCode

func CompileCode(path string) map[string][2]string

CompileCode compiles the solidity code for the specified path. See https://docs.soliditylang.org/zh/v0.8.17/installing-solidity.html#linux to install solc command

func Create

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

Create executes the code using the EVM create method

func Create2

func Create2(input []byte, cfg *Config, salt *uint256.Int) ([]byte, ethcomm.Address, uint64, error)

Create2 executes the code using the EVM create2 method

func Ensure

func Ensure(err error)

func Execute

func Execute(code, input []byte, cfg *Config) ([]byte, *statedb.StateDB, 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.

Execute sets up an in-memory, temporary, environment for the execution of the given code. It makes sure that it's restored to its original state afterwards.

func NewEnv

func NewEnv(cfg *Config) *evm.EVM

func SetDefaults

func SetDefaults(cfg *Config)

SetDefaults sets defaults on the config

func Transfer

func Transfer(db evm.StateDB, sender, recipient common.Address, amount *big.Int)

Transfer subtracts amount from sender and adds amount to recipient using the given PersistStore

Types

type Config

type Config struct {
	ChainConfig *params.ChainConfig
	Difficulty  *big.Int
	Origin      ethcomm.Address
	Coinbase    ethcomm.Address
	BlockNumber *big.Int
	Time        *big.Int
	GasLimit    uint64
	GasPrice    *big.Int
	Value       *big.Int
	Debug       bool
	EVMConfig   evm.Config
	State       *statedb.StateDB
	GetHashFn   func(n uint64) ethcomm.Hash
}

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

type Contract

type Contract struct {
	Abi        abi.ABI
	Cfg        *Config
	Address    common.Address
	AutoCommit bool
}

func Create2Contract

func Create2Contract(cfg *Config, jsonABI, hexCode string, salt uint64, params ...interface{}) *Contract

func CreateContract

func CreateContract(cfg *Config, jsonABI string, hexCode string, params ...interface{}) *Contract

CreateContract create and deploy a contract

func (*Contract) Balance

func (self *Contract) Balance() *big.Int

func (*Contract) BalanceOf

func (self *Contract) BalanceOf(addr common.Address) *big.Int

func (*Contract) Call

func (self *Contract) Call(method string, params ...interface{}) ([]byte, uint64, error)

Jump to

Keyboard shortcuts

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