def broadcast(config): # extracted this out as a separate method so that # this code can be re used elsewhere assert is_ethereum_network(config.network) logger = config.logger from sto.ethereum.broadcast import broadcast as _broadcast dbsession = config.dbsession txs = _broadcast(logger, dbsession, config.network, ethereum_node_url=config.ethereum_node_url, ethereum_private_key=config.ethereum_private_key, ethereum_gas_limit=config.ethereum_gas_limit, ethereum_gas_price=config.ethereum_gas_price) if txs: from sto.ethereum.txservice import EthereumStoredTXService EthereumStoredTXService.print_transactions(txs) logger.info( "Run %ssto tx-update%s to monitor your transaction propagation status", colorama.Fore.LIGHTCYAN_EX, colorama.Fore.RESET) # Write database dbsession.commit()
def last(config: BoardCommmadConfiguration, limit): """Print latest transactions from database. """ assert is_ethereum_network(config.network) logger = config.logger from sto.ethereum.last import get_last_transactions dbsession = config.dbsession txs = get_last_transactions( logger, dbsession, config.network, limit=limit, ethereum_node_url=config.ethereum_node_url, ethereum_private_key=config.ethereum_private_key, ethereum_gas_limit=config.ethereum_gas_limit, ethereum_gas_price=config.ethereum_gas_price) if txs: from sto.ethereum.txservice import EthereumStoredTXService EthereumStoredTXService.print_transactions(txs)
def update(config: BoardCommmadConfiguration): """Update transaction status. Connects to Ethereum network, queries the status of our broadcasted transactions. Then print outs the still currently pending transactions or freshly mined transactions. """ assert is_ethereum_network(config.network) logger = config.logger from sto.ethereum.status import update_status dbsession = config.dbsession txs = update_status(logger, dbsession, config.network, ethereum_node_url=config.ethereum_node_url, ethereum_private_key=config.ethereum_private_key, ethereum_gas_limit=config.ethereum_gas_limit, ethereum_gas_price=config.ethereum_gas_price) if txs: from sto.ethereum.txservice import EthereumStoredTXService EthereumStoredTXService.print_transactions(txs) # Write database dbsession.commit()
def update(config: BoardCommmadConfiguration): """Update transaction status.""" assert is_ethereum_network(config.network) logger = config.logger from sto.ethereum.status import update_status dbsession = config.dbsession txs = update_status(logger, dbsession, config.network, ethereum_node_url=config.ethereum_node_url, ethereum_private_key=config.ethereum_private_key, ethereum_gas_limit=config.ethereum_gas_limit, ethereum_gas_price=config.ethereum_gas_price) if txs: from sto.ethereum.txservice import EthereumStoredTXService EthereumStoredTXService.print_transactions(txs) # Write database dbsession.commit()
def broadcast(config: BoardCommmadConfiguration): """Broadcast waiting transactions.""" assert is_ethereum_network(config.network) logger = config.logger from sto.ethereum.broadcast import broadcast dbsession = config.dbsession txs = broadcast(logger, dbsession, config.network, ethereum_node_url=config.ethereum_node_url, ethereum_private_key=config.ethereum_private_key, ethereum_gas_limit=config.ethereum_gas_limit, ethereum_gas_price=config.ethereum_gas_price) if txs: from sto.ethereum.txservice import EthereumStoredTXService EthereumStoredTXService.print_transactions(txs) logger.info( "Run %ssto tx-update%s to monitor your transaction propagation status", colorama.Fore.LIGHTCYAN_EX, colorama.Fore.RESET) # Write database dbsession.commit()
def issue(config: BoardCommmadConfiguration, symbol, name, amount, transfer_restriction): """Issue out a new security token.""" logger = config.logger assert is_ethereum_network(config.network) # Nothing else implemented yet from sto.ethereum.issuance import deploy_token_contracts from sto.ethereum.txservice import EthereumStoredTXService dbsession = config.dbsession txs = deploy_token_contracts( logger, dbsession, config.network, ethereum_node_url=config.ethereum_node_url, ethereum_abi_file=config.ethereum_abi_file, ethereum_private_key=config.ethereum_private_key, ethereum_gas_limit=config.ethereum_gas_limit, ethereum_gas_price=config.ethereum_gas_price, name=name, symbol=symbol, amount=amount, transfer_restriction=transfer_restriction) EthereumStoredTXService.print_transactions(txs) # Write database dbsession.commit() logger.info("Run %ssto tx-broadcast%s to write this to blockchain", colorama.Fore.LIGHTCYAN_EX, colorama.Fore.RESET)
def past_issuances(config: BoardCommmadConfiguration): """Print out transactions of for tokens issued in the past.""" logger = config.logger from sto.ethereum.issuance import past_issuances dbsession = config.dbsession txs = list(past_issuances(config, dbsession)) if txs: from sto.ethereum.txservice import EthereumStoredTXService EthereumStoredTXService.print_transactions(txs) logger.info("See column %sto%s for token contract addresses", colorama.Fore.LIGHTCYAN_EX, colorama.Fore.RESET) else: logger.info("No issuances")
def verify(config: BoardCommmadConfiguration, contract_addresses: Optional[str] = None): """Verify source code of contract deployment transactions on EtherScan. Users EtherScan API to verify all deployed contracts from the management account. Verify all past contract deployments: sto verify Verify certain deployed contracts: sto verify --contract-addresses=0x1D88fd4fC47711Fc28d105aE2D96A4A9E5c2ae9C,0x57aa933E93Ea627a746DD335c23A90c8D8da825B """ assert is_ethereum_network(config.network) logger = config.logger if contract_addresses: contract_addresses = [c.strip() for c in contract_addresses.split(',')] for addr in contract_addresses: if not is_checksum_address(addr): raise RuntimeError( "Does not look like Ethereum address: {}".format(addr)) from sto.ethereum.issuance import verify_source_code dbsession = config.dbsession txs = verify_source_code(logger, dbsession, config.network, config.etherscan_api_key, addresses=contract_addresses) if txs: from sto.ethereum.txservice import EthereumStoredTXService EthereumStoredTXService.print_transactions(txs) # Write database dbsession.commit()
def verify(config: BoardCommmadConfiguration): """Verify source code of contract deployment transactions on EtherScan. Users EtherScan API to verify all deployed contracts from the management account. """ assert is_ethereum_network(config.network) logger = config.logger from sto.ethereum.issuance import verify_source_code dbsession = config.dbsession txs = verify_source_code(logger, dbsession, config.network, config.etherscan_api_key) if txs: from sto.ethereum.txservice import EthereumStoredTXService EthereumStoredTXService.print_transactions(txs) # Write database dbsession.commit()