예제 #1
0
    def deploy_and_add_smart_token(name, symbol, reserve_ratio_ppm, exchange_contract=None):
        smart_token_result = bt.deploy_smart_token(
            deploying_address=deploying_address,
            name=name, symbol=symbol, decimals=18,
            reserve_deposit_wei=10,
            issue_amount_wei=1000,
            contract_registry_address=registry_address,
            reserve_token_address=reserve_token.address,
            reserve_ratio_ppm=reserve_ratio_ppm
        )

        smart_token_address = smart_token_result['smart_token_address']
        subexchange_address = smart_token_result['subexchange_address']

        smart_token = Token(address=smart_token_address, name=name, symbol=symbol, token_type=TokenType.LIQUID)
        smart_token.decimals = 18

        db.session.add(smart_token)

        if exchange_contract is None:

            exchange_contract = ExchangeContract(
                blockchain_address=subexchange_address,
                contract_registry_blockchain_address=registry_address
            )

        exchange_contract.add_reserve_token(reserve_token)
        exchange_contract.add_token(smart_token, subexchange_address, reserve_ratio_ppm)

        return smart_token, exchange_contract
예제 #2
0
    def deploy(_deploy_data,
               _token_id,
               _exchange_contract_id,
               _creating_org_id=None):
        smart_token_result = bt.deploy_smart_token(**_deploy_data)

        address = smart_token_result['smart_token_address']
        subexchange_address = smart_token_result['subexchange_address']

        _token = Token.query.get(_token_id)
        _token.address = address

        _exchange_contract = ExchangeContract.query.get(_exchange_contract_id)
        _exchange_contract.add_token(_token, subexchange_address,
                                     reserve_ratio_ppm)

        if _creating_org_id:

            _creating_org = Organisation.query.get(_creating_org_id)
            _creating_org.bind_token(_token)
            _creating_org.org_level_transfer_account.set_balance_offset(
                int(_deploy_data['issue_amount_wei'] / 1e16))

            bal = bt.get_wallet_balance(
                _creating_org.primary_blockchain_address, _token)

            print(f'Balance is {bal}')

        db.session.commit()