Пример #1
0
def main():
    api_config = config.read_config()
    instance = api.Api(api_config)

    parser = argparse.ArgumentParser()
    from_address = instance.accounts()[0]
    parser.add_argument('--from_address', default=from_address, help='address to send transactions from')

    subparsers = parser.add_subparsers(help='sub-command help')
    parser_create = subparsers.add_parser('create', help='create the contract')
    parser_create.set_defaults(func=cmd_create)
    parser_create.add_argument('--endowment', type=int, default=500, help='value to endow in ether')

    parser_inspect = subparsers.add_parser('inspect', help='inspect the contract')
    parser_inspect.set_defaults(func=cmd_inspect)
    parser_inspect.add_argument('contract', help='sleth contract address')
    parser_inspect.add_argument('--pending', action='store_true', help='look in pending transactions instead of mined')

    parser_status = subparsers.add_parser('status', help='display the eth node status')
    parser_status.set_defaults(func=cmd_status)

    parser_transact = subparsers.add_parser('transact', help='transact ether to destination (default: 1 ETH)')
    parser_transact.set_defaults(func=cmd_transact)
    parser_transact.add_argument('dest', help='destination')
    parser_transact.add_argument('--value', type=int, default=1, help='value to transfer in ether')

    parser_spin = subparsers.add_parser('spin', help='make a spin')
    parser_spin.set_defaults(func=cmd_spin)
    parser_spin.add_argument('contract', help='sleth contract address')
    parser_spin.add_argument('bet', help='bet amount')

    parser_claim = subparsers.add_parser('claim', help='clain a round')
    parser_claim.set_defaults(func=cmd_claim)
    parser_claim.add_argument('contract', help='sleth contract address')
    parser_claim.add_argument('round', help='round number to claim')

    parser_get_round = subparsers.add_parser('get_round', help='get round information')
    parser_get_round.set_defaults(func=cmd_get_round)
    parser_get_round.add_argument('contract', help='sleth contract address')
    parser_get_round.add_argument('round', help='round number')

    parser_get_current_round = subparsers.add_parser('get_current_round', help='get current round')
    parser_get_current_round.set_defaults(func=cmd_get_current_round)
    parser_get_current_round.add_argument('contract', help='sleth contract address')

    parser_get_stats = subparsers.add_parser('get_stats', help='get contract statistics')
    parser_get_stats.set_defaults(func=cmd_get_stats)
    parser_get_stats.add_argument('contract', help='sleth contract address')

    parser_suicide = subparsers.add_parser('suicide', help='kills the contract')
    parser_suicide.set_defaults(func=cmd_suicide)
    parser_suicide.add_argument('contract', help='sleth contract address')

    args = parser.parse_args()

    print "Using from_address = %s" % (args.from_address)
    instance.address = args.from_address
    args.func(instance, args)
Пример #2
0
import logging

from pyepm import api, config, __version__
from bitcoin import *  # NOQA


BITCOIN_MAINNET = 'btc'
BITCOIN_TESTNET = 'testnet'
SLEEP_TIME = 5 * 60  # 5 mins.  If changing, check retry logic
GAS_FOR_STORE_HEADERS = 1200000  # it should take less than 1M gas, but buffer to avoid running out

CHUNK_SIZE = 5  # number of headers to fetch at a time
CHUNK_RANGE = range(CHUNK_SIZE)

api_config = config.read_config()
instance = api.Api(api_config)

logging.basicConfig(format='%(message)s', level=logging.INFO)
logger = logging.getLogger(__name__)

pyepmLogger = logging.getLogger("pyepm")
pyepmLogger.setLevel(logging.INFO)

# instance.address = "0xcd2a3d9f938e13cd947ec05abc7fe734df8dd826"
# instance.relayContract = "0xba164d1e85526bd5e27fd15ad14b0eae91c45a93"
# TESTNET relay: 0x142f674e911cc55c226af81ac4d6de0a671d4abf

# To use a wallet, deploy and configure https://github.com/ethereum/dapp-bin/blob/69cb5e8c82074b5fbf9c01f75145c3cad5af85e2/wallet/wallet.sol
# Update the 4 wallet variables below.  Using an instance of the contract wallet
# can allow more ETH to be stored in the wallet, while a much smaller amount of
Пример #3
0
def main():
    api_config = config.read_config()
    instance = api.Api(api_config)

    parser = argparse.ArgumentParser()
    from_address = instance.accounts()[0]
    parser.add_argument('--from_address',
                        default=from_address,
                        help='address to send transactions from')

    subparsers = parser.add_subparsers(help='sub-command help')
    parser_create = subparsers.add_parser('create', help='create the contract')
    parser_create.set_defaults(func=cmd_create)
    parser_create.add_argument('--endowment',
                               type=int,
                               default=500,
                               help='value to endow in ether')

    parser_inspect = subparsers.add_parser('inspect',
                                           help='inspect the contract')
    parser_inspect.set_defaults(func=cmd_inspect)
    parser_inspect.add_argument('contract', help='sleth contract address')
    parser_inspect.add_argument(
        '--pending',
        action='store_true',
        help='look in pending transactions instead of mined')

    parser_status = subparsers.add_parser('status',
                                          help='display the eth node status')
    parser_status.set_defaults(func=cmd_status)

    parser_transact = subparsers.add_parser(
        'transact', help='transact ether to destination (default: 1 ETH)')
    parser_transact.set_defaults(func=cmd_transact)
    parser_transact.add_argument('dest', help='destination')
    parser_transact.add_argument('--value',
                                 type=int,
                                 default=1,
                                 help='value to transfer in ether')

    parser_spin = subparsers.add_parser('spin', help='make a spin')
    parser_spin.set_defaults(func=cmd_spin)
    parser_spin.add_argument('contract', help='sleth contract address')
    parser_spin.add_argument('bet', help='bet amount')

    parser_claim = subparsers.add_parser('claim', help='clain a round')
    parser_claim.set_defaults(func=cmd_claim)
    parser_claim.add_argument('contract', help='sleth contract address')
    parser_claim.add_argument('round', help='round number to claim')

    parser_get_round = subparsers.add_parser('get_round',
                                             help='get round information')
    parser_get_round.set_defaults(func=cmd_get_round)
    parser_get_round.add_argument('contract', help='sleth contract address')
    parser_get_round.add_argument('round', help='round number')

    parser_get_current_round = subparsers.add_parser('get_current_round',
                                                     help='get current round')
    parser_get_current_round.set_defaults(func=cmd_get_current_round)
    parser_get_current_round.add_argument('contract',
                                          help='sleth contract address')

    parser_get_stats = subparsers.add_parser('get_stats',
                                             help='get contract statistics')
    parser_get_stats.set_defaults(func=cmd_get_stats)
    parser_get_stats.add_argument('contract', help='sleth contract address')

    parser_suicide = subparsers.add_parser('suicide',
                                           help='kills the contract')
    parser_suicide.set_defaults(func=cmd_suicide)
    parser_suicide.add_argument('contract', help='sleth contract address')

    args = parser.parse_args()

    print "Using from_address = %s" % (args.from_address)
    instance.address = args.from_address
    args.func(instance, args)