Beispiel #1
0
def distribute_single(config: BoardCommmadConfiguration, token_address,
                      to_address, external_id, email, name, amount):
    """Send out tokens to one individual shareholder."""

    logger = config.logger

    assert is_ethereum_network(config.network)  # Nothing else implemented yet
    dbsession = config.dbsession

    from sto.ethereum.distribution import distribute_single

    amount = Decimal(amount)

    result = distribute_single(
        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,
        token_address=token_address,
        to_address=to_address,
        ext_id=external_id,
        email=email,
        name=name,
        amount=amount)

    if result:
        # Write database
        dbsession.commit()
        logger.info(
            "Run %ssto tx-broadcast%s to send out distribured shares to the world",
            colorama.Fore.LIGHTCYAN_EX, colorama.Fore.RESET)
Beispiel #2
0
def send_issuer_tokens(logger, dbsession, web3, private_key_hex, token_address,
                       to_address, amount):
    """Send tokens to a receiver."""
    global _ext_id_counter

    _ext_id_counter += 1
    ext_id = str(_ext_id_counter)

    result = distribute_single(logger,
                               dbsession,
                               "testing",
                               web3,
                               ethereum_abi_file=None,
                               ethereum_private_key=private_key_hex,
                               ethereum_gas_limit=None,
                               ethereum_gas_price=None,
                               token_address=token_address,
                               to_address=to_address,
                               ext_id=ext_id,
                               name=to_address[0:6],
                               email="{}@example.com".format(to_address[0:6]),
                               amount=amount)

    assert result

    broadcast(
        logger,
        dbsession,
        "testing",
        web3,
        ethereum_private_key=private_key_hex,
        ethereum_gas_limit=None,
        ethereum_gas_price=None,
    )