Giter Site home page Giter Site logo

ethersim's Introduction


Warning: moved

EtherSim has been adopted by EthereumJS and subsequently refactored to what is now known as TestRPC

There is also a fork by the amazing guys at NexusDev who did contribute upstream in a true open source spirit. However TestRPC is far better maintained these days and it's recommended devs use it.

What is EtherSim

Join the chat at https://gitter.im/iurimatias/embark-framework

EtherSim is a Limited Ethereum RPC simulator for testing and development purposes. EtherSim is used by the Embark Framework 1.x series

warning

Installation

$ npm install -g ethersim

Usage - as a RPC Server

$ ethersim

Usage - as a Lib

Setup

var EtherSim = require('ethersim');
var sim = new EtherSim.init();

var Web3 = require('web3');
var web3 = new Web3();

web3.setProvider(sim.provider);

Adding accounts

sim.createAccounts(10, function() {})
web3.eth.accounts //=> [..10..accounts..]

Set Balance

sim.setBalance(web3.eth.accounts[0], 123450000, function() {})
web3.eth.getBalance(web3.eth.accounts[0], function(err, balance) {console.log(balance.toNumber())}) //=> 123450000

// send ether from one account to another
web3.eth.sendTransaction({value: 1000, from: web3.eth.accounts[0], to: web3.eth.accounts[1], gasLimit: 10000},function() {console.log("transaction sent")})

// mine transaction
sim.mine()

Time Travel

web3.eth.getBlock('latest') // => current time

sim.jump("5 hours")
sim.mine();

web3.eth.getBlock('latest') // => will be 5 hours ahead

Start Over

sim.reset()

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.