def call(self, dest, from_=DEFAULT_ADDRESS, funid=None, data=None, gas=DEFAULT_GAS, gas_price=GAS_PRICE, value=0): if not dest.startswith("0x"): dest = "0x" + dest if funid is not None: data = "0x" + serpent.encode_abi(funid, *data).encode("hex") params = [{"to": dest, "data": data, "gas": hex(gas), "gasPrice": hex(gas_price), "value": hex(value)}] r = self._rpc_post("eth_call", params) return serpent.decode_datalist(r[2:].decode("hex"))
def transact(self, dest, from_=DEFAULT_ADDRESS, funid=None, data=None, gas=DEFAULT_GAS, gas_price=GAS_PRICE, value=0): if not dest.startswith('0x'): dest = '0x' + dest if funid is not None: data = "0x" + serpent.encode_abi(funid, *data).encode('hex') params = [{ 'to': dest, 'data': data, 'gas': hex(gas), 'gasPrice': hex(gas_price), 'value': hex(value) }] return self._rpc_post('eth_transact', params)
def new_config(data_dir=None): cfg = _get_default_config() if not data_dir: tempfile.mktemp() cfg.set('misc', 'data_dir', data_dir) return cfg ### From here is pasted together from earlier version of pyetherem import serpent from pyethereum import transactions, blocks, processblock, utils #processblock.print_debug = 1 from pyethereum import slogging slogging.set_level('eth.tx',"DEBUG") code = serpent.compile(namecoin_code) key = utils.sha3('cow') addr = utils.privtoaddr(key) genesis = blocks.genesis(new_db(), { addr: 10**18 }) tx1 = transactions.contract(nonce=0,gasprice=10**12,startgas=10000,endowment=0,code=code).sign(key) result, contract = processblock.apply_transaction(genesis,tx1) print genesis.to_dict() tx2 = transactions.Transaction(nonce=1,gasprice=10**12,startgas=10000,to=contract,value=0, data=serpent.encode_abi(0,1,45)).sign(key) result, ans = processblock.apply_transaction(genesis,tx2) serpent.decode_datalist(ans) #print genesis.to_dict()
### From here is pasted together from earlier version of pyetherem import serpent from pyethereum import transactions, blocks, processblock, utils #processblock.print_debug = 1 from pyethereum import slogging slogging.set_level('eth.tx', "DEBUG") code = serpent.compile(namecoin_code) key = utils.sha3('cow') addr = utils.privtoaddr(key) genesis = blocks.genesis(new_db(), {addr: 10**18}) tx1 = transactions.contract(nonce=0, gasprice=10**12, startgas=10000, endowment=0, code=code).sign(key) result, contract = processblock.apply_transaction(genesis, tx1) print genesis.to_dict() tx2 = transactions.Transaction(nonce=1, gasprice=10**12, startgas=10000, to=contract, value=0, data=serpent.encode_abi(0, 1, 45)).sign(key) result, ans = processblock.apply_transaction(genesis, tx2) serpent.decode_datalist(ans) #print genesis.to_dict()