Skip to content

Commit

Permalink
fix run-transactions-simple example and update README, fix #149
Browse files Browse the repository at this point in the history
  • Loading branch information
gasolin committed Jul 28, 2017
1 parent 9fc6e38 commit 5e9fa06
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -33,7 +33,7 @@ Also more examples can be found here
- [old blog post](https://wanderer.github.io/ethereum/nodejs/code/2014/08/12/running-contracts-with-vm/)

# BROWSER
To build for standalone use in the browser install `browserify` and run `npm run build`. This will give you a global variable `EthVM` to use. The standalone file will be at `./dist/ethereumjs-vm.js`
To build for standalone use in the browser, install `browserify` and check [run-transactions-simple exsample](https://github.com/ethereumjs/ethereumjs-vm/tree/master/examples/run-transactions-simple). This will give you a global variable `EthVM` to use. The generated file will be at `./examples/run-transactions-simple/build.js`.

# API
- [`new VM([opts])`](#new-vmstatetrie-blockchain)
Expand All @@ -50,7 +50,7 @@ To build for standalone use in the browser install `browserify` and run `npm run
### `new VM([StateTrie], [blockchain])`
Creates a new VM object
- `StateTrie` - The [Patricia Merkle Tree](https://github.com/wanderer/merkle-patricia-tree) that contains the state. If no trie is given the `VM` will create an in memory trie.
- `blockchain` - an instance of the [`Blockchain`](https://github.com/ethereum/ethereumjs-lib/blob/master/docs/blockchain.md) If no blockchain is given a fake blockchain will be used.
- `blockchain` - an instance of the [`Blockchain`](https://github.com/ethereum/ethereumjs-lib/blob/master/docs/blockchain.md). If no blockchain is given a fake blockchain will be used.
- `opts`
- `state` - the state trie
- `blockchain` - an instance of ethereumjs-blockchain
Expand All @@ -60,7 +60,7 @@ Creates a new VM object


#### `vm.runBlockchain(blockchain, cb)`
Process a transaction.
Process blocks and adds them to the blockchain.
- `blockchain` - A [blockchain](https://github.com/ethereum/ethereumjs-blockchain) that to process
- `cb` - The callback. It is given an err parameter if it fails

Expand Down
21 changes: 21 additions & 0 deletions examples/run-transactions-simple/README.md
@@ -0,0 +1,21 @@
## prerequisite

```
$ npm install -g browserify http-server
```

## Instruction

Run command

```
$ browserify index.js -o bundle.js
```

Then host this folder in a web server

```
$ http-server
```

open http://localhost:8080 in a browser and check the result in web console.
2 changes: 1 addition & 1 deletion examples/run-transactions-simple/index.html
@@ -1 +1 @@
<script src='/index.js'></script>
<script src='/bundle.js'></script>
2 changes: 1 addition & 1 deletion examples/run-transactions-simple/index.js
Expand Up @@ -8,7 +8,7 @@
* this folder onto a HTTP WebServer (such as node-static)
*/

var VM = require('./../../index.js')
var VM = require('../../index.js')

// create a new VM instance
var vm = new VM()
Expand Down

0 comments on commit 5e9fa06

Please sign in to comment.