ethereumjs-vm/examples/run-transactions-simple
https://github.com/ethereumjs/ethereumjs-vm/tree/master/examples/run-transactions-simple
prerequisite先决条件
$ npm install -g browserify http-server
然后还要将package.json中的模块安装了:
npm install
Instruction
Run command
$ browserify index.js -o bundle.js
运行成功后生成:

Then host this folder in a web server
$ http-server
终端:
userdeMacBook-Pro:run-transactions-simple user$ http-server
Starting up http-server, serving ./
Available on:
http://127.0.0.1:8080
http://192.168.1.102:8080
Hit CTRL-C to stop the server
[Sat Dec :: GMT+ (中国标准时间)] "GET /" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Safari/605.1.15"
[Sat Dec :: GMT+ (中国标准时间)] "GET /bundle.js" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Safari/605.1.15"
open http://localhost:8080 in a browser and check the result in web console.
页面运行情况:

查看代码到底做了什么:
index.js
/*
* Example - Running code on an ethereum-vm
*
*
* To run this example in the browser, bundle this file
* with browserify using `browserify index.js -o bundle.js`
* and then load this folder onto a HTTP WebServer (e.g.
* using node-static or `python -mSimpleHTTPServer`).
*/
var Buffer = require('safe-buffer').Buffer // use for Node.js <4.5.0
var VM = require('../../index.js') // create a new VM instance
var vm = new VM() var code = '7f4e616d65526567000000000000000000000000000000000000000000000000003055307f4e616d6552656700000000000000000000000000000000000000000000000000557f436f6e666967000000000000000000000000000000000000000000000000000073661005d2720d855f1d9976f88bb10c1a3398c77f5573661005d2720d855f1d9976f88bb10c1a3398c77f7f436f6e6669670000000000000000000000000000000000000000000000000000553360455560df806100c56000396000f3007f726567697374657200000000000000000000000000000000000000000000000060003514156053576020355415603257005b335415603e5760003354555b6020353360006000a233602035556020353355005b60007f756e72656769737465720000000000000000000000000000000000000000000060003514156082575033545b1560995733335460006000a2600033545560003355005b60007f6b696c6c00000000000000000000000000000000000000000000000000000000600035141560cb575060455433145b1560d25733ff5b6000355460005260206000f3' vm.on('step', function (data) {
console.log(data.opcode.name)
}) vm.runCode({
code: Buffer.from(code, 'hex'),
gasLimit: Buffer.from('ffffffff', 'hex')
}, function (err, results) {
console.log('returned: ' + results.return.toString('hex'))
console.log('gasUsed: ' + results.gasUsed.toString())
console.log(err)
})
其实就是在vm上运行了一段代码
index.html
<script src='/bundle.js'></script>
ethereumjs-vm/examples/run-transactions-simple的更多相关文章
- Qt Examples Qt实例汇总
ActiveQt Examples Using ActiveX from Qt applications. Animation Framework Examples Doing animations ...
- ethereumjs/browser-builds
https://github.com/ethereumjs/browser-builds ethereumjs - Browser Builds This repository contains br ...
- ethereumjs/ethereumjs-vm-4-tests
根据代码发现还要了解的模块有: ethereumjs/merkle-patricia-tree -对应数据存储的数据结构 ethereumjs-blockchain —— 区块链 ethereumjs ...
- Extended VM Disk In VirtualBox or VMware (虚拟机磁盘扩容)
First, Clean VM all snapshot, and poweroff your VM. vmdk: vmware-vdiskmanager -x 16GB myDisk.vmdk vd ...
- 学习 java命令
依稀记得自己第一次编译*.java文件,第一次运行*.class文件.但是六七年过去了,现在运行java写的程序更多的是用tomcat这种web容器.最近有个小需求,写一个监控zookeeper集群的 ...
- Java Annotations: Explored & Explained--转载
原文地址:http://www.javacodegeeks.com/2012/08/java-annotations-explored-explained.html One of the many w ...
- ormlite 文档
目录[-] A Fast, Simple, Typed ORM for .NET Download 8 flavours of OrmLite is on NuGet: Docs and Downlo ...
- C++开源库集合
| Main | Site Index | Download | mimetic A free/GPL C++ MIME Library mimetic is a free/GPL Email lib ...
- mininet安装,使用
http://mininet.org/download/ http://sdnhub.cn/index.php/mininet-walkthrough-chinese/ --------------- ...
- Java programming language compiler
https://docs.oracle.com/javase/7/docs/technotes/tools/windows/javac.html\ javac - Java programming l ...
随机推荐
- fb登陆遇到傻逼问题
centos中curl需要ssl的支持, 所以我重新安装了curl,并安装了openssl-devel,这个是依赖,必须的. so 完美
- HDFS 的运行机制
hdfs haddop distributed system 由 name node, secondary name node,data node, client 组成. 真正存放数据的就是 data ...
- Bash拾遗:变量
使用引号包裹变量 在<高级Bash脚本编程指南>中的4.1节中有这么个例子: hello="A B C D" echo $hello # A B C D echo &q ...
- PHP获取地址栏传的id值
function getQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&] ...
- Struts2 数据校验之四兄弟
现在是科技的时代,大多数人都在网上购物了, 我们都碰到过相同的问题,各大网站弄的那些各种各样的注册页面,相信大家都深有体会. 有了这验证就很好的保证了我们的信息的准确性和安全性. 接下来我给大家讲解一 ...
- js-js的不重载
* 什么是重载?方法名相同,参数列表不同 - Java里面有重载 * js里面不存在重载! <html> <head> <title>World</title ...
- CSS知多少
1.Cascading Style Sheets 层叠样式表 2.层叠就是浏览器对多个样式来源进行叠加,最终确定结果的过程. 3. 样式的5大来源:浏览器默认样式.浏览器用户自定义样式.行内样式.内部 ...
- JavaScript的进阶之路(五)理解数组2
数组方法 //定义一个测试数组 var array1 = [1,2,5,null,"a"]; //join()方法是String.split()方法的逆操作,后者是将字符串分割成若 ...
- Windows下本机简易监控系统搭建(Telegraf+Influxdb+Grafana)
一.文件准备 1.1 文件名称 telegraf-1.2.1_windows_amd64.zip influxdb-1.2.2_windows_amd64.zip grafana-4.2.0.wind ...
- [转] Linux 3.10 ARM Device Tree 的初始化
[转] Linux 3.10 ARM Device Tree 的初始化 本文代码均来自标准 linux kernel 3.10,可以到这里下载 https://www.kernel.org/ ...