@ -75,11 +75,12 @@ class EthIpc(object):
def call ( self , address , sig , args , result_types ) :
'''
Call a contract function on the R PC server , without sending a
Call a contract function on the I PC server , without sending a
transaction ( useful for reading data )
'''
data = self . _encode_function ( sig , args )
data_hex = data . encode ( ' hex ' )
# could be made to use web3py directly, but instead uses eth_call which is adapted
response = self . eth_call ( to_address = address , data = data_hex )
return decode_abi ( result_types , response [ 2 : ] . decode ( ' hex ' ) )
@ -104,7 +105,6 @@ class EthIpc(object):
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #web3_clientversion
http : / / web3py . readthedocs . io / en / latest / web3 . version . html #web3.version.Version.node
'''
return self . web3 . version . node
@ -130,8 +130,8 @@ class EthIpc(object):
def net_listening ( self ) :
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #net_listening
ONLY indirectly available
TESTED
Only indirectly available
'''
return self . web3net . listening ( )
@ -139,7 +139,7 @@ class EthIpc(object):
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #net_peercount
ONLY indirectly available
TESTED
'''
return self . web3 . net . peerCount ( )
@ -181,7 +181,7 @@ class EthIpc(object):
http : / / web3py . readthedocs . io / en / latest / web3 . eth . html ? highlight = syncing #web3.eth.Eth.hashrate
'''
return hex_to_dec ( web3 . eth . hashrate )
return web3 . eth . hashrate
def eth_gasPrice ( self ) :
'''
@ -189,7 +189,7 @@ class EthIpc(object):
http : / / web3py . readthedocs . io / en / latest / web3 . eth . html ? highlight = gasprice #web3.eth.Eth.gasPrice
'''
return hex_to_dec ( web3 . eth . gasPrice )
return web3 . eth . gasPrice
def eth_accounts ( self ) :
'''
@ -205,7 +205,7 @@ class EthIpc(object):
http : / / web3py . readthedocs . io / en / latest / web3 . eth . html ? highlight = gasprice #web3.eth.Eth.blockNumber
'''
return hex_to_dec ( self . web3 . eth . blockNumber )
return self . web3 . eth . blockNumber
def eth_getBalance ( self , address = None , block = BLOCK_TAG_LATEST ) :
'''
@ -256,8 +256,9 @@ class EthIpc(object):
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_getunclecountbyblockhash
http : / / web3py . readthedocs . io / en / latest / web3 . eth . html ? highlight = gasprice #web3.eth.Eth.getUncle
( not implemented with convenience functions )
'''
return self . web3 . manager . request_blocking ( ' eth_getUncleCountByBlockHash ' , [ block_hash ] )
return self . web3 . eth . getUncleCount ( block_hash )
def eth_getUncleCountByBlockNumber ( self , block = BLOCK_TAG_LATEST ) :
@ -267,13 +268,13 @@ class EthIpc(object):
'''
block = validate_block ( block )
self . web3 . manager . request_blocking ( ' debug_getBlockRlp ' , [ number ] )
return self . web3 . eth . getUncleCount ( block )
def eth_getCode ( self , address , default_block = BLOCK_TAG_LATEST ) :
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_getcode
http : / / web3py . readthedocs . io / en / latest / web3 . eth . html ? highlight = gasprice #web3.eth.Eth.getCode
NEEDS TESTING
'''
if isinstance ( default_block , str ) :
if default_block not in BLOCK_TAGS :
@ -285,7 +286,6 @@ class EthIpc(object):
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_sign
http : / / web3py . readthedocs . io / en / latest / web3 . eth . html ? highlight = gasprice #web3.eth.Eth.sign
either data = hexstr = or text = probably not needed now but if used should be differentiated
NEEDS TESTING
'''
return self . web3 . eth . sign ( address , data )
@ -294,7 +294,6 @@ class EthIpc(object):
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_sendtransaction
http : / / web3py . readthedocs . io / en / latest / web3 . eth . html ? highlight = syncing #web3.eth.Eth.sendTransaction
NEEDS TESTING
'''
params = { }
params [ ' from ' ] = from_address or self . eth_coinbase ( )
@ -316,7 +315,6 @@ class EthIpc(object):
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_sendrawtransaction
http : / / web3py . readthedocs . io / en / latest / web3 . eth . html ? highlight = syncing #web3.eth.Eth.sendRawTransaction
NEEDS TESTING
'''
return self . web3 . eth . sendRawTransaction ( data )
@ -326,7 +324,6 @@ class EthIpc(object):
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_call
http : / / web3py . readthedocs . io / en / latest / web3 . eth . html ? highlight = syncing #web3.eth.Eth.call
NEEDS TESTING
'''
if isinstance ( default_block , str ) :
if default_block not in BLOCK_TAGS :
@ -350,7 +347,6 @@ class EthIpc(object):
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_estimategas
http : / / web3py . readthedocs . io / en / latest / web3 . eth . html ? highlight = gasprice #web3.eth.Eth.estimateGas
NEEDS TESTING
'''
if isinstance ( default_block , str ) :
if default_block not in BLOCK_TAGS :
@ -374,7 +370,6 @@ class EthIpc(object):
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_getblockbyhash
http : / / web3py . readthedocs . io / en / latest / web3 . eth . html ? highlight = gasprice #web3.eth.Eth.getBlock
TESTED
'''
return self . web3 . eth . getBlock ( block_identifier = block_hash , full_transactions = tx_objects )
@ -382,7 +377,6 @@ class EthIpc(object):
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_getblockbynumber
http : / / web3py . readthedocs . io / en / latest / web3 . eth . html ? highlight = gasprice #web3.eth.Eth.getBlock
TESTED
'''
block = validate_block ( block )
return self . web3 . eth . getBlock ( block_identifier = block , full_transactions = tx_objects )
@ -391,7 +385,6 @@ class EthIpc(object):
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_gettransactionbyhash
http : / / web3py . readthedocs . io / en / latest / web3 . eth . html ? highlight = gasprice #web3.eth.Eth.getTransaction
TESTED
'''
return self . web3 . eth . getTransactionByHash ( tx_hash )
@ -399,7 +392,6 @@ class EthIpc(object):
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_gettransactionbyblockhashandindex
http : / / web3py . readthedocs . io / en / latest / web3 . eth . html #web3.eth.Eth.getTransactionFromBlock
TESTED
'''
return self . web3 . eth . getTransactionFromBlock ( block_identifier = block_hash , transaction_index = index )
@ -408,7 +400,6 @@ class EthIpc(object):
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_gettransactionbyblocknumberandindex
http : / / web3py . readthedocs . io / en / latest / web3 . eth . html #web3.eth.Eth.getTransactionFromBlock
TESTED
'''
block = validate_block ( block )
return self . web3 . eth . getTransactionFromBlock ( block_identifier = block , transaction_index = index )
@ -417,64 +408,60 @@ class EthIpc(object):
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_gettransactionreceipt
http : / / web3py . readthedocs . io / en / latest / web3 . eth . html ? highlight = gasprice #web3.eth.Eth.getTransactionReceipt
TESTED
'''
return self . web3 . eth . getTransactionReceipt ( tx_hash )
def eth_getUncleByBlockHashAndIndex ( self , block_hash , index = 0 ) :
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_getunclebyblockhashandindex
NOT IMPLEMENTED
TESTED
Indirectly accessible
self . web3 . manager . request_blocking ( ' rpc/ipc function ' , [ params ] )
'''
return " Not implemented "
return self . web3 . manager . request_blocking ( ' eth_getUncleByBlockHashAndIndex ' , [ block_hash , web3 . toHex ( index ) ] )
def eth_getUncleByBlockNumberAndIndex ( self , block = BLOCK_TAG_LATEST , index = 0 ) :
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_getunclebyblocknumberandindex
NOT IMPLEMENTED
TESTED
Indirectly accessible
'''
block = validate_block ( block )
return " Not implemented "
return self . web3 . manager . request_blocking ( ' eth_getUncleByBlockNumberAndIndex ' , [ block , web3 . toHex ( index ) ] )
def eth_getCompilers ( self ) :
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_getcompilers
Does not seem to be implemented
TESTED
Indirectly implemented
'''
return " Not implemented "
return self . web3 . manager . request_blocking ( ' eth_getCompilers ' )
def eth_compileSolidity ( self , code ) :
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_compilesolidity
Implemented ?
TESTED
Indirectly implemented
'''
return self . web3 . eth . compileSolidity ( code )
return self . web3 . manager . request_blocking ( ' eth_compileSolidity ' , [ code ] )
def eth_compileLLL ( self , code ) :
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_compilelll
Implemented ?
N / A
Indirectly accessible
'''
return self . web3 . eth . compileLLL ( code )
return self . web3 . manager . request_blocking ( ' eth_compileLLL ' , [ code ] )
def eth_compileSerpent ( self , code ) :
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_compileserpent
Implemented ?
N / A
Indirectly implemented
'''
return self . web3 . eth . compileSerpent ( code )
return self . web3 . manager . request_blocking ( ' eth_compileSerpent ' , [ code ] )
def eth_newFilter ( self , from_block = BLOCK_TAG_LATEST , to_block = BLOCK_TAG_LATEST , address = None , topics = None ) :
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_newfilter
http : / / web3py . readthedocs . io / en / latest / web3 . eth . html #web3.eth.Eth.filter
NEEDS TESTING
'''
filter_params = {
' fromBlock ' : from_block ,
@ -488,7 +475,6 @@ class EthIpc(object):
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_newblockfilter
http : / / web3py . readthedocs . io / en / latest / web3 . eth . html #web3.eth.Eth.filter
TESTED
'''
return self . web3 . eth . newFilter ( ' latest ' )
@ -496,7 +482,6 @@ class EthIpc(object):
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_newpendingtransactionfilter
http : / / web3py . readthedocs . io / en / latest / web3 . eth . html #web3.eth.Eth.filter
TESTED
'''
return self . web3 . eth . newFilter ( ' pending ' )
@ -504,7 +489,6 @@ class EthIpc(object):
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_uninstallfilter
http : / / web3py . readthedocs . io / en / latest / web3 . eth . html #web3.eth.Eth.uninstallFilter
NEEDS TESTING
'''
return self . web3 . eth . uninstallFilter ( filter_id )
@ -512,7 +496,6 @@ class EthIpc(object):
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_getfilterchanges
http : / / web3py . readthedocs . io / en / latest / web3 . eth . html #web3.eth.Eth.getFilterChanges
NEEDS TESTING
'''
return self . web3 . eth . getFilterChanges ( filter_id )
@ -520,7 +503,6 @@ class EthIpc(object):
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_getfilterlogs
http : / / web3py . readthedocs . io / en / latest / web3 . eth . html #web3.eth.Eth.getFilterLogs
NEEDS TESTING
'''
return self . web3 . eth . getFilterLogs ( filter_id )
@ -528,7 +510,6 @@ class EthIpc(object):
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_getlogs
http : / / web3py . readthedocs . io / en / latest / filters . html ? highlight = getLogs #web3.utils.filters.LogFilter.get
NEEDS TESTING
'''
return self . filter_object . get ( )
@ -536,164 +517,117 @@ class EthIpc(object):
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_getwork
http : / / web3py . readthedocs . io / en / latest / releases . html ? highlight = getWork #id15
TESTED
'''
return self . web3 . eth . getWork ( )
def eth_submitWork ( self , nonce , header , mix_digest ) :
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_submitwork
Not sure if implemented
NEEDS TESTING
Implemented indirectly
'''
return self . web3 . eth . submitWork ( nonce , header , mix_digest )
return self . web3 . manager . request_blocking ( ' eth_submitWork ' , [ nonce , header , mix_digest ] )
def eth_submitHashrate ( self , hash_rate , client_id ) :
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #eth_submithashrate
Not sure if implemented
TESTED
'''
return self . web3 . eth . submitHashrate ( hash_rate , client_id )
def db_putString ( self , db_name , key , value ) :
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #db_putstring
Not implemented I think
TESTED
'''
warnings . warn ( ' deprecated ' , DeprecationWarning )
return self . web3 . db . putString ( db_name , key , value )
def db_getString ( self , db_name , key ) :
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #db_getstring
Not implemented I think
TESTED
'''
warnings . warn ( ' deprecated ' , DeprecationWarning )
return self . web3 . db . getString ( db_name , key )
def db_putHex ( self , db_name , key , value ) :
Implemented indirectly
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #db_puthex
TESTED
'''
if not value . startswith ( ' 0x ' ) :
value = ' 0x {} ' . format ( value )
warnings . warn ( ' deprecated ' , DeprecationWarning )
return self . web3 . db . putHex ( db_name , key , value )
def db_getHex ( self , db_name , key ) :
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #db_gethex
TESTED
'''
warnings . warn ( ' deprecated ' , DeprecationWarning )
return self . web3 . db . getHex ( db_name , key )
return self . web3 . manager . request_blocking ( ' eth_submitHashrate ' , [ hash_rate , client_id ] )
def shh_version ( self ) :
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #shh_version
http : / / web3py . readthedocs . io / en / latest / web3 . shh . html #web3.shh.Shh.version
N / A
'''
return self . web3 . shh . version ( )
def shh_post ( self , topics , payload , priority , ttl , from_ = None , to = None ) :
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #shh_post
NEEDS TESTING
http : / / web3py . readthedocs . io / en / latest / web3 . shh . html #web3.shh.Shh.post
# only topics and payload are necessary according to web3.py
'''
whisper_object = {
' from ' : from_ ,
' to ' : to ,
' topics ' : topics ,
' payload ' : payload ,
' priority ' : h ex( priority ) ,
' ttl ' : h ex( ttl ) ,
' topics ' : web3 . toHex ( topics ) ,
' payload ' : web3 . toHex ( payload ) ,
' priority ' : web3 . toHex ( priority ) ,
' ttl ' : web3 . toHex ( ttl )
}
return self . _call ( ' shh_post ' , [ whisper_object ] )
return self . web3 . shh . post ( whisper_object )
def shh_newIdentity ( self ) :
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #shh_newidentity
N / A
http : / / web3py . readthedocs . io / en / latest / web3 . shh . html #web3.shh.Shh.newIdentity
'''
return self . _call ( ' shh_newIdentity ' )
return self . web3 . shh . newIdentity ( )
def shh_hasIdentity ( self , address ) :
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #shh_hasidentity
NEEDS TESTING
http : / / web3py . readthedocs . io / en / latest / web3 . shh . html #web3.shh.Shh.hasIdentity
'''
return self . _call ( ' shh_hasIdentity ' , [ address ] )
return self . web3 . shh . hasIdentity ( address )
def shh_newGroup ( self ) :
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #shh_newgroup
N / A
http : / / web3py . readthedocs . io / en / latest / web3 . shh . html #web3.shh.Shh.newGroup
'''
return self . _call ( ' shh_newGroup ' )
return self . web3 . shh . newGroup ( )
def shh_addToGroup ( self ) :
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #shh_addtogroup
NEEDS TESTING
http : / / web3py . readthedocs . io / en / latest / web3 . shh . html #web3.shh.Shh.addToGroup
'''
return self . _call ( ' shh_addToGroup ' )
return self . web3 . shh . addToGroup ( )
def shh_newFilter ( self , to , topics ) :
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #shh_newfilter
NEEDS TESTING
http : / / web3py . readthedocs . io / en / latest / web3 . shh . html #web3.shh.Shh.filter
# to is optional
'''
_filter = {
' to ' : to ,
' topics ' : topics ,
' to ' : to
}
return self . _call ( ' shh_newFilter ' , [ _filter ] )
return self . web3 . shh . newFilter ( _filter )
def shh_uninstallFilter ( self , filter_id ) :
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #shh_uninstallfilter
NEEDS TESTING
http : / / web3py . readthedocs . io / en / latest / web3 . shh . html #web3.shh.Shh.uninstallFilter
'''
return self . _call ( ' shh_uninstallFilter ' , [ filter_id ] )
return self . web3 . shh . uninstallFilter ( filter_id )
def shh_getFilterChanges ( self , filter_id ) :
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #shh_getfilterchanges
http : / / web3py . readthedocs . io / en / latest / web3 . eth . html ? highlight = syncing #web3.eth.Eth.getFilterChanges
NEEDS TESTING
'''
filt = self . web3 . eth . filter ( )
return self . _call ( ' shh_getFilterChanges ' , [ filter_id ] )
return self . web3 . shh . getFilterChanges ( filter_id )
def shh_getMessages ( self , filter_id ) :
'''
https : / / github . com / ethereum / wiki / wiki / JSON - RPC #shh_getmessages
NEEDS TESTING
http : / / web3py . readthedocs . io / en / latest / web3 . shh . html #web3.shh.Shh.getMessages
'''
return self . _call ( ' shh_getMessages ' , [ filter_id ] )
return self . web3 . shh . getMessages ( filter_id )
def getBlockRlp ( self , number = 0 ) :
return self . _call ( ' debug_getBlockRlp ' , [ number ] )
#not accessible with convenience functions
return self . web3 . manager . request_blocking ( ' debug_getBlockRlp ' , [ number ] )
def traceTransaction ( self , txHash ) :
#atm not directly accessible, so something like this is needed
#https://github.com/pipermerriam/web3.py/issues/308
#web3.manager.request_blocking('debug_traceTransaction', ["TX_ID_AS_HEX_STRING"])
return self . web3 . manager . request_blocking ( ' debug_traceTransaction ' , [ txHash ] )