コード例 #1
0
ファイル: smartcontracts.py プロジェクト: sekmet/raiden
def fund_node(
    token_result: Callable[[], Contract],
    proxy_manager: ProxyManager,
    to_address: Address,
    amount: TokenAmount,
) -> None:
    token_contract = token_result()
    token_proxy = proxy_manager.token(
        TokenAddress(to_canonical_address(token_contract.address)),
        BLOCK_ID_LATEST)
    token_proxy.transfer(to_address=to_address, amount=amount)
コード例 #2
0
def deploy_tokens_and_fund_accounts(
    token_amount: TokenAmount,
    number_of_tokens: int,
    proxy_manager: ProxyManager,
    participants: List[Address],
    contract_manager: ContractManager,
    token_contract_name: str,
) -> List[TokenAddress]:
    """ Deploy `number_of_tokens` ERC20 token instances with `token_amount` minted and
    distributed among `blockchain_services`. Optionally the instances will be registered with
    the raiden registry.

    Args:
        token_amount: number of units that will be created per token
        number_of_tokens: number of token instances that will be created
        proxy_manager: the proxy manager used to create the token proxy
        participants: participant addresses that will receive tokens
    """
    result = list()
    for _ in range(number_of_tokens):
        token_address = TokenAddress(
            deploy_contract_web3(
                contract_name=token_contract_name,
                deploy_client=proxy_manager.client,
                contract_manager=contract_manager,
                constructor_arguments=(token_amount, 2, "raiden", "Rd"),
            ))

        result.append(token_address)

        # only the creator of the token starts with a balance (deploy_service),
        # transfer from the creator to the other nodes
        for transfer_to in participants:
            proxy_manager.token(token_address).transfer(
                to_address=transfer_to,
                amount=TokenAmount(token_amount // len(participants)))

    return result