以太坊JSON-RPC客户端

pyethmobisir的Python项目详细描述


pyethmobisir
==


ethereum的python客户端,使用json-rpc接口

*完成:实现所有62个json-rpc方法和多个特定于客户端的方法
*提供一个高级接口,用于在区块链上创建合约并调用合约方法

代码::bash

$sudo apt install python minimal
$sudo apt install gcc
$sudo apt install virtualenv;可选,但建议在ubuntu 14.04上安装$sudo apt install libpython dev
$sudo apt install libssl dev


。代码::bash

$sudo apt get install python virtualenv;可选,但建议
$sudo apt get install libpython dev
$sudo apt get install libssl dev



代码::bash

$pip install pyethmobisir




确保有一个运行以太坊客户端(如geth)的节点供库连接。

代码::python

>;>c.web3_clientversion()
u'geth/v1.3.3/linux/go1.5.1'
>;>c.eth_gasprice()
50000000000
>;>c.eth_u blocknumber()
828948




高级功能性
----


这些示例假定以下简单的一致性契约:

……代码:

contract example{

string s;


代码::bash

$solc—二进制标准输出示例。sol



setup
``````

…代码::python

>;>;编译='606060405261020F806100136000396000F300606040526000357C0100000000000000000000000000000000000000000000000000000004806375D74F3914610044578063E7AAB290146100BD576100425650B005B61004F6004506101565B604051806020018281038252838151815260200150805190602001908083826004602084601F0104600302600F01F15015090810190601F1680156100AF57808203805160018360200361010000A0319168152602001915050925050505080910390F35B61010D6004803590602001906001803590602001919080601F016020910402602001604051908101604052809391908152602001838082843782050505090506010F565B005B8060006000509080519060200190828054825590600052602060002090601F01602090048101921560160579182015B8281111561015F578251826005055916020019060010190610141565B5061018B919061016D565B808211156101876008150600005060010166D565B5090565B50505B0519015081016040528060008152602001506000050805480601F016020809104026000160405190810160405280929181526020018280548015610200578201919060005260200020905B8154815290600101906020018083116101E357829001F1682015B505050505050505061020C565B9056'
>;;从pyethmobisir导入ethsonrpc以使用奇偶校验特定方法,导入parityethjsonrpc
>;>;c=ethjsonrpc('127.0.0.1',8545)



代码::python

>>>从上往下继续
>;contract\u tx=c.create\u contract(c.eth\u coinbase(),compiled,gas=300000)
>;>在这里等待开采新区块时创建合同
>;contract_addr=c.get_contract_address(contract_tx)
>;gt;协定地址
u'0x24988147f230450103d8c42c43182cf226857'



代码::python

>>>从上往下继续
>;tx=c.call_with_transaction(c.eth_coinbase(),contract_addr,"set_s(string)",['hello,world'])
>;tx
u'0x15bde63d79466e3db5169a913bb2069130ca387033d2ff2e29f4dfbef1bc6e0d'


代码::python

>>>从上往下继续
>;results=c.call(contract_addr,'get_s()',[],['string'])
>>>results
['hello,world']



其他示例
----


有关其他示例,请参见"test.py"。


>实现的JSON-RPC方法
----


*web3客户端版本
*web3客户端版本
*net版本
*net监听
*净peercount
*eth协议版本
*eth同步
*eth coinbase
*eth挖掘
*eth hashrate
*eth gasprice
*eth账户
*eth blocknumber
*eth getbalance
*eth getstorageat
*eth gettransactioncount
*eth getblocktransactioncountbyhash
*eth-getBlockTransactionCountByNumber
*eth-getUncleCountByBlockHash
*eth-getUncleCountByBlockNumber
*eth-getcode
*eth-sign
*eth-sendTransaction
*eth-sendRawTransaction
*eth-call
*eth-estimateGas
*eth-getBlockByHash
*eth-getBlockByNumber
*eth gettransactionbyhash
*eth gettransactionbyblockhashandindex
*eth gettransactionbyblocknumberandindex
*eth gettransactionreceipt
*eth getunclebyblockhashandindex
*eth getunclebyblocknumberandindex
*eth getcompilers
*eth getcompileslidity
*eth嫒compilell
*eth嫒compileserpent
*eth嫒newfilter
*eth嫒newlockfilter
*eth嫒uninstallfilter
*eth嫒getfilterChanges
*eth嫒getfilterLogs
*eth嫒getwork
*eth嫒submithashrate
*eth嫒submithashrate
*数据库putstring
*数据库putstring
*数据库putshex
*数据库putshex
*数据库putshex
*SHH U版本
*SHH U post
*SHH U newidentity
*SHH U haseidentity
*SHH U newgroup
*SHH U addtogroup
*SHH U newfilter
*SHH U newfilter
*SHH U uniuninstallfilter
*SHH U getfiltercchanges
*SHH U get留言
*SHH U get留言
*SHH U get留言
*SHH U留言

仅奇偶校验json-rpc方法要使用这些方法,确保

*作为客户端运行奇偶校验
*使用此库的"parity ethjsonrpc"客户端(而不是普通的"ethjsonrpc"客户端)运行*跟踪块

reference
----


*https://github.com/ethereum/wiki/wiki/json-rpc
*https://github.com/ethcore/parity/wiki/jsonrpc跟踪模块

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
分别使用椭圆曲线密码对文本消息进行java加密和解密   java如何将JTable滚动到特定值?   java JSP登录注销简单web应用程序,使用bean在数据库中存在数据时返回false   java无法编译,未设置类路径,包不存在?   java为什么这一变量会受到影响?   集合为什么Java在Map中没有putIfAbsent(key,supplier)方法?   安卓在Java中计算仿真时间   java初始化方法在主类中的指定方法之前运行   java如何在hadoop的reduce中将genericWritable恢复为用户定义的可写?   如何使用java替换pdf中的文本   参数不适用于ASP服务器的java HttpPost   创建对象时的java NullPointerException   Java JPanel中的swing图形有问题,但它在一个框架中工作   java Android Studio在硬件设备上运行时出错   google api类路径的java空指针异常   java如何将InputStream转换为DataHandler?   java在多个Jetty服务器之间共享连接池