sibyl

package module
v0.0.0-...-3ec6173 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: MIT Imports: 12 Imported by: 0

README

sibyl

A more embedded version of fxfactorial/run-evm-code. This tool makes it easy to apply transactions to the current EVM state. Call it a transaction simulator or what not.

Usage

// Create a new simulator using geth chaindata.
simulator, err := sybil.NewGethSimulator("geth/chaindata")
if err != nil {
    log.Panic(err)
}

// Fork to a specified block number
err = simulator.Fork(blockNumber)
if err != nil {
    log.Panic(err)
}

// Simulate a static call.
ret, err := simulator.StaticCall(sender, to, input, gas)
if err != nil {
    log.Panic(err)
}

fmt.Println(hexutil.Encode(result))

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Simulator

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

Simulator is a transaction simulator, allowing you to run transactions against the current blockchain state

func NewGethSimulator

func NewGethSimulator(path string) (*Simulator, error)

NewGethSimulator returns a new simulator that utilizes the go-ethereum LevelDB Database.

func NewSimulator

func NewSimulator(blockchain *core.BlockChain) *Simulator

NewSimulator returns a bare simulator

func (*Simulator) Call

func (s *Simulator) Call(sender, to common.Address, input []byte, gas uint64, value *big.Int) ([]byte, error)

Call executes an EVM call on the current context

func (*Simulator) Fork

func (s *Simulator) Fork(blockNumber uint64) error

Fork creates a new temporary context with the state for a given block number

func (*Simulator) Rollback

func (s *Simulator) Rollback(snapshot int)

Rollback rolls the state back to a specific snapshot

func (*Simulator) Snapshot

func (s *Simulator) Snapshot() int

Snapshot takes a snapshot of the current state

func (*Simulator) StaticCall

func (s *Simulator) StaticCall(sender, to common.Address, input []byte, gas uint64) ([]byte, error)

StaticCall executes an EVM static call on the current context

Jump to

Keyboard shortcuts

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