serpent语言的第一个智能合约
2016-12-08 19:56
405 查看
Linux安装In order to install the Serpent python library and executable do:
git clone https://github.com/ethereum/serpent.git $ cd serpent $ git checkout develop $ make && sudo make install $ python setup.py installYou can install pyethereum itself as well:
$ git clone https://github.com/ethereum/pyethereum.git $ cd pyethereum $ git checkout develop $ pip install -r requirements.txt $ python setup.py install
用serpent写的文件保存为.se文件。然后进去所在的文件夹。再进去python,然后比如说运行register.se
def register(key, value): # Key not yet claimed if not self.storage[key]: self.storage[key] = value return(1) else: return(0) # Key already claimed def ask(key): return(self.storage[key]
进入pythony以后按下面运行,所有的前三句是一样的
>>> from ethereum import tester as t >>> s = t.state()//initializes a new state (ie. a genesis block). >>> c = s.abi_contract('namecoin.se')// creates a new contract, and creates an object in Python which represents it. >>> c.register(0x67656f726765, 45)//注册kEY=0x67656````` 1 >>> c.register(0x67656f726765, 20) 0 >>> c.register(0x6861727279, 65) 1 >>> c.ask(0x6861727279) 65
相关文章推荐
- 算法训练 未名湖边的烦恼
- 二维码集成
- 实验11——指针的基础应用
- 如何衡量存储系统的可靠性
- 【C2065】未声明的标识符
- BZOJ 1036 [ZJOI2008] 树的统计Count
- 使用CoordinatorLayout
- Map-Reduce
- 为github帐号添加SSH keys
- 【Dongle】【Java】从字符串中获得二维数组
- OpenCV学习笔记(五):OpenCV2.4.13+VS2013的配置(非本机使用)
- EventBus粘性事件
- 跳跃表(skiplist)实现及简单分析
- mongodb数组和嵌入文档操作
- iPhone6爆炸真是小概率事件吗?
- 南邮微机实验(基于中断的动态显示)
- Express jade
- 阶乘函数
- LA 3041 Colored Cubes (暴力枚举+贪心)
- 实验11——指针的基础应用