From 1e8954db24a10c306c0e36d4f51628fb244ff146 Mon Sep 17 00:00:00 2001 From: xuelei Date: Sat, 5 Aug 2017 15:26:37 +0800 Subject: [PATCH] fix bug: param data should start with '0x' --- ethjsonrpc/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ethjsonrpc/client.py b/ethjsonrpc/client.py index 89a9edb..4eda185 100644 --- a/ethjsonrpc/client.py +++ b/ethjsonrpc/client.py @@ -113,7 +113,7 @@ def call(self, address, sig, args, result_types): transaction (useful for reading data) ''' data = self._encode_function(sig, args) - data_hex = data.encode('hex') + data_hex = '0x' + data.encode('hex') response = self.eth_call(to_address=address, data=data_hex) return decode_abi(result_types, response[2:].decode('hex')) @@ -125,7 +125,7 @@ def call_with_transaction(self, from_, address, sig, args, gas=None, gas_price=N gas = gas or self.DEFAULT_GAS_PER_TX gas_price = gas_price or self.DEFAULT_GAS_PRICE data = self._encode_function(sig, args) - data_hex = data.encode('hex') + data_hex = '0x' + data.encode('hex') return self.eth_sendTransaction(from_address=from_, to_address=address, data=data_hex, gas=gas, gas_price=gas_price, value=value)