import logging as log
import time
from func_setups import FuncSetups



fs = FuncSetups()


eth_rop = fs.create_proxy('https://ropsten.infura.io:443')
eth_inf = fs.create_proxy()

keystore = fs.create_keystore()
account = fs.get_account(keystore, 0)
account2 = fs.get_account(keystore, 1)


def prep_n_sign_tx(nonce, value):
    utx = eth_inf.prepare_transaction(to_address=account2,
                                      from_address=account,
                                      nonce=nonce,
                                      gas=100001,
                                      value=value)
    (stx, errcode, errmsg) = keystore.sign_transaction(account, utx)
    return stx   

def check_for_tx(tx_hash):
    tx_data = eth_inf.eth_getTransactionByHash(tx_hash)
    if tx_data and tx_data['blockNumber']: #  means it's published     
        return (tx_data['value'],tx_data['blockNumber'],tx_data['transactionIndex'] ) 
Beispiel #2
0
import logging as log
import time

from eth_proxy import TransactionDelegate, SolcCaller
from func_setups import FuncSetups

fs = FuncSetups()


#
# Create a simple contract with ctor params
#
contract_src = \
    '''
    pragma solidity ^0.4.0;     
    contract TheTestContract 
    {
        // publics
        int32 public aPublicInt = 111;
            
        // private'ish
        address _ownerAddr;
    
        // Gas measured: ?? TODO
        function TheTestContract(int32 newInt) 
        {
            aPublicInt = newInt;
            _ownerAddr = msg.sender;
        }
        
        function SetTheInt(int32 newInt)
Beispiel #3
0
    print('--------------------')     
    if rcpt:
        print("   Transaction Hash: {0}".format(rcpt['transactionHash']))               
        print("  Transaction Index: {0}".format(maybe_decode_int(rcpt['transactionIndex'])))
        print("         Block Hash: {0}".format(rcpt['blockHash']))
        print("      Block Nummber: {0}".format(maybe_decode_int(rcpt['blockNumber'])))                   
        print("Cumulative Gas Used: {0}".format(maybe_decode_int(rcpt['cumulativeGasUsed']))) 
        print("           Gas Used: {0}".format(maybe_decode_int(rcpt['gasUsed']))) 
        print("   Contract Address: {0}".format(rcpt['contractAddress']))  
        print_tx_logs(rcpt['logs']) 
    else:
        print("None.")
                 
# - - - - - - 

fs = FuncSetups()


#eth = fs.create_proxy()
#eth = fs.create_proxy('https://propsten.infura.io:443')
#eth = fs.create_proxy('http://localhost:8545')
eth = fs.create_proxy('https://infuranet.infura.io:443')

tx_obj = eth.eth_getTransactionByHash(tx_hash)
if tx_obj is None:
    print("TX not found.")     
    exit()
    
print_tx_info(tx_obj)

rcpt = eth.eth_getTransactionReceipt(tx_hash)
import logging as log
import time

from eth_proxy.solc_caller import SolcCaller
from func_setups import FuncSetups

fs = FuncSetups()

# the EthProxy
eth = fs.create_proxy()
#eth = fs.create_proxy('https://propsten.infura.io:443')
#eth = fs.create_proxy('http://localhost:8545')

block = eth.eth_blockNumber()  # Trivial test (are we connected?)
print("\neth_blockNumber(): {0}".format(block))

keystore = fs.create_keystore()

account = fs.get_account(keystore, 0)
account2 = fs.get_account(keystore, 1)

# A global nonce for "account"
nonce = eth.eth_getTransactionCount(account, return_raw=False)
print("nonce: {0}".format(nonce))

def wait_for_tx(tx_hash, timeout=300):
    '''
    returns (succeeded, contract_addr)  addr is none if not a contract
    '''
    addr = None
Beispiel #5
0
#
def insert_library_address(bytecode, libspec, address):
    '''
    libscpe is <source_path>:<LibraryName>
    ie" ./base/contract/bob.sol:BobContract"
    '''
    print("\n\n{0}".format(bytecode))
    pat = '__({0})__+'.format(libspec)
    newcode = re.sub(pat, address, bytecode, 0)
    print("\n\n{0}".format(newcode))
    return newcode


# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

fs = FuncSetups()

lib_path = fs.write_temp_contract("test-lib.sol", lib_src)
lib2_path = fs.write_temp_contract("test-lib2.sol", lib2_src)
lib_folder = os.path.dirname(lib_path)

os.chdir(lib_folder)
lib_path = "./test-lib.sol"
lib2_path = "./test-lib2.sol"

# insert actual library source path,
# needs to happen because files are written to temp
caller_src = str.replace(caller_src, '{{libpath}}', lib_path)
caller_src = str.replace(caller_src, '{{lib2path}}', lib2_path)
caller_path = fs.write_temp_contract("test_caller.sol", caller_src)
import logging as log
from eth_proxy import EthProxyHttp, EthNodeSigner
from eth_proxy import EthContract
from func_setups import FuncSetups

fs = FuncSetups()

# End-to-end test using EthContract abstraction
# in synchronous mode (for quickie development)


#
# Create a simple contract with ctor params
#
# contract_src = \
#     '''
#     pragma solidity ^0.4.0;     
#     contract TheTestContract 
#     {
#         // publics
#         int32 public aPublicInt = 111;
#             
#         // private'ish
#         address _ownerAddr;
#     
#         // Gas measured: ?? TODO
#         function TheTestContract(int32 newInt) 
#         {
#             aPublicInt = newInt;
#             _ownerAddr = msg.sender;
#         }
import logging as log
import time
import json
from eth_proxy.solc_caller import SolcCaller
from eth_proxy.pyeth_client.eth_utils import sha3
from func_setups import FuncSetups


fs = FuncSetups()

# the EthProxy
eth = fs.create_proxy()

block = eth.eth_blockNumber()  # Trivial test (are we connected?)
print("\neth_blockNumber(): {0}".format(block))

keystore = fs.create_keystore()

account = fs.get_account(keystore, 0)
account2 = fs.get_account(keystore, 1)

# make some data:
#
# Keystore sign_data signs a HASH (hex string form)
#
data = {'acct': account,
        'acct2': account2,
        'two': 2 }

jdata = json.dumps(data)
import logging as log
from eth_proxy import EthProxyHttp, EthNodeSigner
from eth_proxy import EthContract
from eth_proxy.pyeth_client.eth_utils import sha3
from eth_proxy.utils import bytes_to_str
from func_setups import FuncSetups

fs = FuncSetups()

# End-to-end test using EthContract abstraction
# in synchronous mode (for quickie development)

#
# Create a simple contract with ctor params
#
contract_src = \
    '''
    pragma solidity ^0.4.0;  
    contract TheTestContract 
    {
        // publics
        string unititializedStorageString;
        
        bytes32 constant nullStringHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        
        mapping (address => string ) _stringsByAddr;
               
        // Gas measured: ?? TODO
        function TheTestContract() 
        {
            _stringsByAddr[msg.sender] = 'owner';
import logging as log
from eth_proxy import EthProxyHttp, EthNodeSigner
from eth_proxy import EthContract
from func_setups import FuncSetups

fs = FuncSetups()

# End-to-end test using EthContract abstraction
# in synchronous mode (for quickie development)

#
# Create a simple contract with ctor params
#
# contract_src = \
#     '''
#     pragma solidity ^0.4.0;
#     contract TheTestContract
#     {
#         // publics
#         int32 public aPublicInt = 111;
#
#         // private'ish
#         address _ownerAddr;
#
#         // Gas measured: ?? TODO
#         function TheTestContract(int32 newInt)
#         {
#             aPublicInt = newInt;
#             _ownerAddr = msg.sender;
#         }
#
Beispiel #10
0
from eth_proxy.node_signer import EthNodeSigner
from eth_proxy.solc_caller import SolcCaller
from func_setups import FuncSetups

fs = FuncSetups()

# the EthProxy
eth = fs.create_proxy()
#eth = fs.create_proxy('http://localhost:8545')

block = eth.eth_blockNumber()  # Trivial test (are we connected?)
print("\neth_blockNumber(): {0}".format(block))

keystore = fs.create_keystore()

account = fs.get_account(keystore, 0)
account2 = fs.get_account(keystore, 1)

# Set up eth for this account
eth.set_eth_signer(keystore)

#
# Simple transaction
#

print("\nSimple Transaction from {0} to {1}".format(account, account2))

tx_data = eth.submit_transaction_sync(from_address=account,
                                      to_address=account2,
                                      data=None,
                                      gas=500001,
import logging as log
import time
from func_setups import FuncSetups

fs = FuncSetups()

eth_rop = fs.create_proxy('https://ropsten.infura.io:443')
eth_inf = fs.create_proxy()

keystore = fs.create_keystore()
account = fs.get_account(keystore, 0)
account2 = fs.get_account(keystore, 1)


def prep_n_sign_tx(nonce, value):
    utx = eth_inf.prepare_transaction(to_address=account2,
                                      from_address=account,
                                      nonce=nonce,
                                      gas=100001,
                                      value=value)
    (stx, errcode, errmsg) = keystore.sign_transaction(account, utx)
    return stx


def check_for_tx(tx_hash):
    tx_data = eth_inf.eth_getTransactionByHash(tx_hash)
    if tx_data and tx_data['blockNumber']:  #  means it's published
        return (tx_data['value'], tx_data['blockNumber'],
                tx_data['transactionIndex'])
    else:
        return None
Beispiel #12
0
# Use to check EthContract.link_library()
#
def insert_library_address(bytecode, libspec, address):
    '''
    libscpe is <source_path>:<LibraryName>
    ie" ./base/contract/bob.sol:BobContract"
    '''    
    print("\n\n{0}".format(bytecode))
    pat = '__({0})__+'.format(libspec)
    newcode = re.sub(pat,address,bytecode,0)
    print("\n\n{0}".format(newcode))
    return newcode
    
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

fs = FuncSetups()

lib_path = fs.write_temp_contract("test-lib.sol", lib_src)   
lib2_path = fs.write_temp_contract("test-lib2.sol", lib2_src)   
lib_folder = os.path.dirname(lib_path)


os.chdir(lib_folder)
lib_path = "./test-lib.sol"
lib2_path = "./test-lib2.sol"

# insert actual library source path,
# needs to happen because files are written to temp
caller_src = str.replace(caller_src, '{{libpath}}', lib_path)
caller_src = str.replace(caller_src, '{{lib2path}}', lib2_path)
caller_path = fs.write_temp_contract("test_caller.sol", caller_src)