Skip to content

Releases: iurimatias/EtherSim

EtherSim 0.4.0

25 May 16:17
Compare
Choose a tag to compare

What is EtherSim


EtherSim is an Ethereum simulator for testing and development purposes. It is used by several frameworks including:

Thanks


The bulk of the contributions to this release were made by Ryan Casey from MakerDAO. A big thanks to them for supporting community projects.

In this release


This releases updates to the latest ethereumjs-vm libs which fix an issue where sometimes the balance of account was not being correctly updated.

Setup

You can use Ethersim as a server (just run ethersim) or as a library:

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()

EtherSim 0.3.0

14 Mar 10:46
Compare
Choose a tag to compare

What is EtherSim


EtherSim is an Ethereum simulator for testing and development purposes. It is used by several frameworks including:

Thanks


The bulk of the contributions to this release were made by Ryan Casey from MakerDAO. A big thanks to them for supporting community projects.

In this release


Both functionalities as a server and as a lib have been greatly improved. Events are now supported as well as new functionalities.

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()