Code Monkey home page Code Monkey logo

levm's Introduction

levm - Little Ethereum Virtual Machine

Run smart contracts on the Ethereum Virtual Machine (EVM) without the Ethereum blockchain.

I created this to make it a little easier to use the EVM in other projects, and for testing smart contracts.

levm.New(...) creates a small wrapper for the ethereum virtual machine, and sets up the EVM with default parameters and the required stateDB.

โ†“ Installation

This project only has two dependencies. (go-ethereum contains the EVM, and splashkeys is an ecdsa key library)

go get github.com/CryptoKass/levm

Dependencies

  • go get github.com/ethereum/go-ethereum
  • go get github.com/CryptoKass/splashkeys

Example

This is Example is located in the example sub-directory:

func main() {

	//make a new address evm
	fromAddr = tools.NewRandomAddress()

	//Load a contract from file
	abiObject, binData, err := tools.LoadContract("contract/example_sol_Example.abi", "contract/example_sol_Example.bin")
	fmt.Println("Abi\n", abiObject.Methods)

	// create new levm instance
	lvm := levm.New("./db", big.NewInt(0), fromAddr)

	// create a new account and set the balance
	// (needs enough balance to cover gas cost)
	lvm.NewAccount(fromAddr, big.NewInt(1e18))

	// deploy a contract
	code, addr, gas, err := lvm.DeployContract(fromAddr, binData)
	fmt.Println("contract code length:", len(code))
	fmt.Printf("contract address: %x\n", addr)
	fmt.Println("unused gas:", gas)
	fmt.Println("errors:", err)

}

contact: [email protected] ๐Ÿ‘

HELP WANTED would be great if you would create an issue if you find a bug.

levm's People

Contributors

cryptokass avatar zzyzydb avatar

Stargazers

Qiuyu Ding avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.