crossbar.network._api

Classes

Network

XBR Network backend API exposed for client applications.

Module Contents

class Network(config)[source]

Bases: autobahn.twisted.wamp.ApplicationSession

XBR Network backend API exposed for client applications.

Note

This API covers the global parts of the XBR Network - APIs to individual XBR Data Markets, XBR Data Catalogs and XBR Cloud Domains are exposed by crossbar.

XBR_COIN_OID[source]
_bc_gw_config[source]
_chain_id[source]
_db[source]
_dbpath = b'.'[source]
_eth_acct[source]
_eth_adr[source]
_eth_adr_raw[source]
_eth_privkey[source]
_ipfs_files_directory[source]
_ipfs_files_path[source]
_mailgun_from[source]
_mailgw[source]
_markets_whitelist = [][source]
_meta[source]
_network[source]
_reactor[source]
_status = 'starting'[source]
_w3[source]
_xbr[source]
_xbrnetwork[source]
backup_wallet(member_oid: bytes, wallet_data: bytes, signature: bytes, details: autobahn.wamp.types.CallDetails | None = None) bytes[source]

If the account is using a hosted wallet (account wallet_type == "hosted"), after creating a new client wallet private key, the client should upload the (encrypted) private key - encrypted with a password - by calling this procedure. A hosted wallet can be restored by calling xbr.network.recover_wallet.

Parameters:
  • member_oid – ID of the member to backup the hosted wallet for.

  • wallet_data – Encrypted, serialized wallet data to backup. A maximum of 64kB can be stored.

  • signature

  • details (autobahn.wamp.types.CallDetails) – Caller details.

Returns:

SHA256 hash computed over wallet_data

static check_config(personality, extra: Dict | None) Dict[source]

Check component extra configuration from ComponentConfig.extra.

Parameters:

extra (dict) – Dictionary with component configuration.

Returns:

Normalized and auto-substituted configuration.

Return type:

dict

async create_catalog(member_oid: bytes, catalog_oid: bytes, verifying_chain_id: int, current_block_number: int, verifying_contract_adr: bytes, terms_hash: str | None, meta_hash: str | None, meta_data: bytes | None, signature: bytes, attributes: dict | None, details: autobahn.wamp.types.CallDetails | None = None) dict[source]

Create a new XBR Data FbsRepository.

Parameters:
  • member_oid – OID of the member to create the catalog under (the member will become catalog owner.).

  • catalog_oid – OID of the new catalog.

  • verifying_chain_id – Blockchain ID.

  • current_block_number – Blockchain current block number.

  • verifying_contract_adr – Address of XBRNetwork smart contract.

  • terms_hash – Multihash for optional catalog terms that apply to the catalog and all APIs published to that catalog.

  • meta_hash – Mutlihash for optional off-chain catalog meta-data.

  • meta_data – Optional off-chain catalog meta-data.

  • attributes – Object standard attributes like title, description and tags.

  • signature – EIP712 signature for the catalog market creation.

  • details (autobahn.wamp.types.CallDetails) – Caller details.

Returns:

Data catalog creation information.

async create_coin(member_oid: bytes, coin_oid: bytes, chain_id: int, block_number: int, contract_adr: bytes, name: str, symbol: str, decimals: int, initial_supply: bytes, meta_hash: str | None, meta_data: bytes | None, signature: bytes, attributes: dict | None, details: autobahn.wamp.types.CallDetails | None = None) dict[source]

Create a new ERC20 coin for use in data markets as a means of payment.

Parameters:
  • member_oid

  • coin_oid

  • chain_id – Blockchain ID.

  • block_number – Blockchain current block number.

  • contract_adr – Address of verifying contract.

  • name

  • symbol

  • decimals

  • initial_supply

  • meta_hash

  • meta_data

  • attributes

  • signature – EIP712 signature for the coin creation.

  • attributes – Coin attributes.

  • details – Caller details.

Returns:

Coin creation information.

create_domain(member_oid: bytes, chain_id: int, block_number: int, contract_adr: bytes, signature: bytes, details: autobahn.wamp.types.CallDetails | None = None)[source]

Create a new XBR Cloud Domain.

Parameters:
  • member_oid – ID of the member to create the cloud domain under - the member will be owner.

  • chain_id – Blockchain ID.

  • block_number – Blockchain current block number.

  • contract_adr – Address of XBRNetwork smart contract.

  • signature – EIP712 signature (computed over the fields chain_id, block_number, contract_adr, …) for the data market creation.

  • details (autobahn.wamp.types.CallDetails) – Caller details.

Returns:

Cloud domain creation information.

async create_market(member_oid: bytes, market_oid: bytes, verifying_chain_id: int, current_block_number: int, verifying_contract_adr: bytes, coin_adr: bytes, terms_hash: str | None, meta_hash: str | None, meta_data: bytes | None, market_maker_adr: bytes, provider_security: bytes, consumer_security: bytes, market_fee: bytes, signature: bytes, attributes: dict | None, details: autobahn.wamp.types.CallDetails | None = None) dict[source]

Create a new XBR Data Market.

See also

Unit test test_api05_market.py

Parameters:
  • member_oid – Member who will own the market and act as a market operator. Usually the calling member.

  • market_oid – New globally unique market OID (a 16-bytes UUID).

  • verifying_chain_id – Blockchain ID (eg 1 for Ethereum mainnet, 4 for Rinkeby, etc).

  • current_block_number – Current block number on blockchain.

  • verifying_contract_adr – Address of verifying contract.

  • coin_adr

  • terms_hash

  • meta_hash

  • meta_data

  • market_maker_adr

  • provider_security

  • consumer_security

  • market_fee

  • signature – EIP712 signature (computed over the fields chain_id, block_number, contract_adr, …) for the data market creation.

  • attributes – Market attributes.

  • details – Caller details.

Returns:

Data market creation information.

async does_hash_exist(ipfs_hash: str, details: autobahn.wamp.types.CallDetails | None = None)[source]
echo(*args, **kwargs)[source]

Test/Development test procedure: echo back any and all positional arguments and keywords arguments given.

  • Procedure: xbr.network.echo

  • Errors: wamp.error.*

See also

Unit test test_api_echo.py

Parameters:
  • args (list) – Arbitrary positional call arguments - returned “as is”.

  • kwargs (dict) – Arbitrary keyword call arguments - returned “as is”.

  • details (autobahn.wamp.types.CallDetails) – Caller details.

Returns:

The positional and keyword arguments as provided to the call.

Return type:

autobahn.wamp.types.CallResult

async find_apis(created_from: int | None = None, limit: int | None = None, include_owners: List[bytes] | None = None, include_catalogs: List[bytes] | None = None, include_titles: List[str] | None = None, include_descriptions: List[str] | None = None, include_tags: List[str] | None = None, details: autobahn.wamp.types.CallDetails | None = None) List[bytes][source]

Search for XBR APIs by

  • owning member

  • catalog(s) the APIs are published in

  • descriptive title, description and tags

as well as specify range and limit of the searched blockchain blocks and returned APIs.

See also

Unit test fixme.py

Note

When a specific filter is not provided, the filter remains un-applied and respective APIs are not filtered in the results. Specifically, when called without any arguments, this procedure will return all existing APIs. The pagination via created_from and limit still applies.

Parameters:
  • created_from – Only return APIs published within blocks not earlier than this block number.

  • limit – Only return APIs from this many blocks beginning with block created_from. So limit is in number of blocks and must be a positive integer when provided.

To search for APIs, the following filters can be used:

Parameters:
  • include_owners – If provided, only return APIs owned by any of the owners specified.

  • include_catalogs – If provided, only return APIs published to a catalog in this list.

  • include_titles – If provided, only return catalogs with a title that contains any of the specified titles.

  • include_descriptions – If provided, only return catalogs with a description that contains any of the specified descriptions.

  • include_tags – If provided, only return catalogs with a tag that contains any of the specified tags.

FOR INTERNAL USE

Parameters:

details (autobahn.wamp.types.CallDetails) – DO NOT USE. Caller details internally provided by the router and cannot be used as an application level parameter.

Returns:

List of OIDs of APIs matching the search criteria.

async find_catalogs(created_from: int | None = None, limit: int | None = None, include_owners: List[bytes] | None = None, include_apis: List[bytes] | None = None, include_titles: List[str] | None = None, include_descriptions: List[str] | None = None, include_tags: List[str] | None = None, details: autobahn.wamp.types.CallDetails | None = None) List[bytes][source]

Search for XBR Data Catalogs by

  • owning member and joined actors

  • descriptive title, description and tags

  • APIs published to catalogs

as well as specify range and limit of the searched blockchain blocks and returned catalogs.

See also

Unit test fixme.py

Note

When a specific filter is not provided, the filter remains un-applied and respective catalogs are not filtered in the results. Specifically, when called without any arguments, this procedure will return all existing catalogs. The pagination via created_from and limit still applies.

Parameters:
  • created_from – Only return catalogs created within blocks not earlier than this block number.

  • limit – Only return catalogs from this many blocks beginning with block created_from. So limit is in number of blocks and must be a positive integer when provided.

To search for catalogs, the following filters can be used:

Parameters:
  • include_owners – If provided, only return catalogs owned by any of the owners specified.

  • include_apis – If provided, only return catalogs containing any of the APIs specified.

  • include_titles – If provided, only return catalogs with a title that contains any of the specified titles.

  • include_descriptions – If provided, only return catalogs with a description that contains any of the specified descriptions.

  • include_tags – If provided, only return catalogs with a tag that contains any of the specified tags.

FOR INTERNAL USE

Parameters:

details (autobahn.wamp.types.CallDetails) – DO NOT USE. Caller details internally provided by the router and cannot be used as an application level parameter.

Returns:

List of OIDs of catalogs matching the search criteria.

async find_coins(created_from: int | None = None, limit: int | None = None, include_owners: List[bytes] | None = None, include_names: List[str] | None = None, details: autobahn.wamp.types.CallDetails | None = None) List[bytes][source]
Parameters:
  • created_from

  • limit

  • include_owners

  • include_names

  • details

Returns:

find_domains(include_owners: list | None = None, include_titles: list | None = None, include_descs: list | None = None, include_tags: list | None = None, details: autobahn.wamp.types.CallDetails | None = None)[source]

Search for XBR Cloud Domains by owner, label, description, tags, etc.

Parameters:
  • include_owners – If provided, only return cloud domains owned by any of the owners specified.

  • include_titles – If provided, only return cloud domains with a title that contains any of the specified titles.

  • include_descs – If provided, only return cloud domains with a description that contains any of the specified descriptions.

  • include_tags – If provided, only return cloud domains with a tag that contains any of the specified tags.

  • details (autobahn.wamp.types.CallDetails) – Caller details.

Returns:

List of addresses of cloud domains matching the search criteria.

async find_markets(created_from: int | None = None, limit: int | None = None, include_owners: List[bytes] | None = None, include_actors: List[bytes] | None = None, include_titles: List[str] | None = None, include_descriptions: List[str] | None = None, include_tags: List[str] | None = None, include_apis: List[bytes] | None = None, details: autobahn.wamp.types.CallDetails | None = None) List[bytes][source]

Search for XBR Data Markets by

  • owning member and joined actors

  • descriptive title, description and tags

  • APIs implemented by data services offered in markets

as well as specify range and limit of the searched blockchain blocks and returned markets.

See also

Unit test test_api05_market.py

Note

When a specific filter is not provided, the filter remains un-applied and respective markets are not filtered in the results. Specifically, when called without any arguments, this procedure will return all existing markets. The pagination via created_from and limit still applies.

Parameters:
  • created_from – Only return markets created within blocks not earlier than this block number.

  • limit

    Only return markets from this many blocks beginning with block created_from. So limit is in number of blocks and must be a positive integer when provided.

    Note

    Since limit can not be smaller than one block, and since the number of markets created in blocks can vary per-block, the number of returned markets is only limited by the number of markets that could be technically created within one block given the block gas limit of the respective blockchain. Currently, the largest XBR contract is XBRNetwork which consumes 5,278,476 gas out of a 10,000,000 maximum on Rinkeby. Which means, the number of markets returned per block is 0 or 1, and hence the number of markets returned is always <= limit. But this should not be assumed as refactoring the XBR contracts might result in a smaller maximum contract size per created market.

To search for markets, the following filters can be used:

Parameters:
  • include_owners – If provided, only return markets owned by any of the owners specified.

  • include_actors – If provided, only return markets joined by any of the actorss specified.

  • include_titles – If provided, only return markets with a title that contains any of the specified titles.

  • include_descriptions – If provided, only return markets with a description that contains any of the specified descriptions.

  • include_tags – If provided, only return markets with a tag that contains any of the specified tags.

  • include_apis – If provided, only return markets with services providing an API of any of the specified APIs.

FOR INTERNAL USE

Parameters:

details (autobahn.wamp.types.CallDetails) – DO NOT USE. Caller details internally provided by the router and cannot be used as an application level parameter.

Returns:

List of addresses of markets matching the search criteria.

get_actor_in_market(market_oid: bytes, actor_adr: bytes, details: autobahn.wamp.types.CallDetails | None = None) list[source]

Get information on an actor in a market.

Parameters:
  • market_oid – ID of the market the actor is joined to.

  • actor_adr – Address the actor joined to the market.

  • details (autobahn.wamp.types.CallDetails) – Caller details.

Returns:

Information on the actor in the market.

get_actors_in_market(market_oid: bytes, details: autobahn.wamp.types.CallDetails | None = None) list[source]

Get list of market actors in a given market.

Parameters:
Returns:

List of addresses of markets joined by the given actor.

get_api(api_oid: bytes, include_attributes: bool = False, details: autobahn.wamp.types.CallDetails | None = None) dict[source]

Retrieve basic information for the given XBR API.

Parameters:
Returns:

API information.

get_catalog(catalog_oid: bytes, include_attributes: bool = False, details: autobahn.wamp.types.CallDetails | None = None) dict[source]

Retrieve basic information for the given XBR Data FbsRepository.

Parameters:
Returns:

FbsRepository information.

get_catalogs_by_owner(member_oid: bytes, details: autobahn.wamp.types.CallDetails | None = None)[source]

Get list of XBR Data Catalogs owned by the given member.

Parameters:
Returns:

List of OIDs of catalogs owned by the given member.

get_coin(coin_oid: bytes, include_attributes: bool = False, details: autobahn.wamp.types.CallDetails | None = None) dict | None[source]

Retrieve basic information for the given ERC20 coin for markets.

Parameters:
  • market_oid – OID of the XBR Data Market to retrieve information for.

  • include_attributes – If set, include all attributes set on the market.

  • details (autobahn.wamp.types.CallDetails) – Caller details.

Returns:

Market information.

async get_coin_balance(member_oid: bytes, coin_oid: bytes, details: autobahn.wamp.types.CallDetails | None = None) bytes[source]

Get the current balance in the given coins, held by the given member.

Parameters:
Returns:

Current balance of given member and coin.

get_coin_by_symbol(symbol: str, details: autobahn.wamp.types.CallDetails | None = None) bytes | None[source]

Get coin by coin name.

Parameters:
Returns:

If found, the OID of the coin.

async get_config(include_eula_text: bool = False, details: autobahn.wamp.types.CallDetails | None = None) dict[source]

Get backend configuration / settings.

  • Procedure: xbr.network.get_status

  • Errors: wamp.error.*

Note

All configuration settings here are security-insensitive (“harmless”) and public.

See also

Unit test test_api_echo.py

Parameters:

details (autobahn.wamp.types.CallDetails) – Caller details.

Returns:

Current backend status information. For example:

{
    "now": 1573675753141788247,
    "chain": 4,
    "contracts": {
        "xbrtoken": "0x78890bF748639B82D225FA804553FcDBe5819576",
        "xbrnetwork": "0x96f2b95733066aD7982a7E8ce58FC91d12bfbB2c",
    }
    "eula": {
        "hash": "QmV1eeDextSdUrRUQp9tUXF8SdvVeykaiwYLgrXHHVyULY",
        "url": "https://raw.githubusercontent.com/crossbario/xbr-protocol/master/ipfs/xbr-eula/XBR-EULA.txt",
        "text": "XBR End User License Agreement (EULA) ..."
    }
    "from": "The XBR project <no-reply@mailing.crossbar.io>"
}
  • now: Current time (number of nanoseconds since the Unix epoch).

  • chain: Chain ID (blockchain network).

  • contracts: Addresses of XBR smart contract instances (on-chain):

    • xbrtoken: On-chain address of XBRToken contract.

    • xbrnetwork: On-chain address of XBRNetwork contract.

  • eula: Current XBR network EULA (IPFS Multihash):

    • url: Web URL to download EULA text.

    • hash: Hash of EULA text.

    • text: Actual EULA text.

  • from: Email sending address for system emails.

get_domain(domain_adr: bytes, details: autobahn.wamp.types.CallDetails | None = None)[source]

Retrieve basic information for the given XBR Cloud Domain.

Parameters:
Returns:

Domain information.

get_domains_by_owner(member_oid: bytes, details: autobahn.wamp.types.CallDetails | None = None)[source]

Get list of XBR Cloud Domains owned by the given member.

Parameters:
Returns:

List of addresses of domains owned by the given member.

async get_gas_price(details: autobahn.wamp.types.CallDetails | None = None) bytes[source]
Parameters:

details

Returns:

async get_market(market_oid: bytes, include_attributes: bool | None = False, include_terms_text: bool | None = False, details: autobahn.wamp.types.CallDetails | None = None) dict[source]

Retrieve basic information for the given XBR Data Market.

See also

Unit test test_api05_market.py

Note

Given a market_adr, this API here provides the same market information as the Market-maker API for the respective market. The difference is, the procedure is more general, in that it can return (basic) market information for any market, and in that the procedure is implemented in the planet.xbr.network backend rather than the XBR market maker running on the Crossbar.io edge node of the operator of the respective market.

Parameters:
  • market_oid – OID of the XBR Data Market to retrieve information for.

  • include_attributes – If set, include all attributes set on the market.

  • include_terms_text – If set, download market terms text from Infura’s IPFS gateway and include in the response.

  • details (autobahn.wamp.types.CallDetails) – Caller details.

Returns:

Market information.

get_markets_by_actor(actor_oid: bytes, details: autobahn.wamp.types.CallDetails | None = None) list[source]

Get list of XBR Data Markets the actor is joined to.

Parameters:
Returns:

List of markets joined by the given actor.

get_markets_by_coin(coin_oid: bytes, details: autobahn.wamp.types.CallDetails | None = None) list[source]

Get list of XBR Data Markets using a specific coin as a means of payment.

Parameters:
Returns:

List of addresses of markets using the specified coin as a means of payment.

get_markets_by_owner(owner_oid: bytes, details: autobahn.wamp.types.CallDetails | None = None) list[source]

Get list of XBR Data Markets owned by the given member.

Parameters:
Returns:

List of markets owned by the given member.

async get_member(member_oid: bytes, details: autobahn.wamp.types.CallDetails | None = None) dict[source]

Retrieve information for member given member ID (not wallet address).

See also

Unit test test_api04_member.py

Parameters:
Returns:

Member information. For example:

{
    'oid': b'¬aÅ¿mÑ­»Í[GËM÷cE',
    'created': 1582281124907755461,
    'level': 1,
    'address': b'¦e¤!pxRÈéCMßNˆœ„K',
    'username': 'somebody'
    'email': 'somebody@nodomain',
    'eula': 'QmcU74QYcPQJCPUVVRwguVfrSnt8ZJrnbXzYPhxfhey7Qb',
    'profile': 'QmV1eeDextSdUrRUQp9tUXF8SdvVeykaiwYLgrXHHVyULY',
    'balance': {
        'eth': b'',
        'xbr': b''
    },
    'catalogs': 0,
    'domains': 0,
    'markets': 0,
}

async get_member_by_wallet(wallet_adr: bytes, details: autobahn.wamp.types.CallDetails | None = None) dict | None[source]

Retrieve information for member given member wallet address (not member ID).

See also

Unit test test_api04_member.py

Parameters:
Returns:

Member information.

get_member_login(member_oid: bytes, client_pubkey: bytes, details: autobahn.wamp.types.CallDetails | None = None) dict[source]

Get client key details.

See also

Unit test test_api04_member.py

Parameters:
  • member_oid – ID of the member of which to retrieve a client key for. This MUST be identical to the caller of this procedure - only client keys for the currently authenticated member can be retrieved.

  • details (autobahn.wamp.types.CallDetails) – Caller details.

Returns:

Client key information.

get_member_logins(member_oid: bytes, details: autobahn.wamp.types.CallDetails | None = None) list[source]

Get client keys currently associated with the member.

See also

Unit test test_api04_member.py

Parameters:
  • member_oid – ID of the member of which to retrieve client keys for. This MUST be identical to the caller of this procedure - only the list of client keys for the currently authenticated member can be retrieved.

  • details (autobahn.wamp.types.CallDetails) – Caller details.

Returns:

List of client public keys currently associated with the member.

async get_status(details: autobahn.wamp.types.CallDetails | None = None) dict[source]

Get backend status.

  • Procedure: xbr.network.get_status

  • Errors: wamp.error.*

See also

Unit test test_api01_echo.py

Parameters:

details (autobahn.wamp.types.CallDetails) – Caller details.

Returns:

Current backend status information. For example:

{
    "now": 1573675753141788247,
    "status": "ready",
    "chain": 4,
    "block": {
        "number": 5958028,
        "hash": b"",
        "gas_limit": 10000000,
    }
}
  • now: Current time (number of nanoseconds since the Unix epoch).

  • status: Current system status (one of ["starting", "ready", "stopping"]).

  • chain: Chain ID (blockchain network).

  • block: Current block information:

    • number: Current block number

    • hash: Current block hash

    • gas_limit: Current block gas limit

async get_transaction_receipt(transaction: bytes, details: autobahn.wamp.types.CallDetails | None = None) dict[source]
Parameters:
  • transaction

  • details

Returns:

ident[source]
async is_member(wallet_adr: bytes, details: autobahn.wamp.types.CallDetails | None = None) bool[source]

Check if the given Ethereum address is a member in the XBR network.

Note

This procedure is public and can be called by anyone. However, membership information if public anyways, since membership is tracked on-chain.

Parameters:
Returns:

Flag indicating whether the address is a member or not.

async join_market(member_id: bytes, market_id: bytes, chain_id: int, block_number: int, contract_adr: bytes, actor_type: int, meta_hash: bytes | None, meta_data: bytes | None, signature: bytes, details: autobahn.wamp.types.CallDetails | None = None) dict[source]

Join an existing data market as a buyer (data consumer) and/or seller (data provider).

If all is fine with the supplied information, the joining member will be sent a verification email to members primary email.

Once the Web link contained in the verification email is clicked, the xbrnetwork.Api.verify_join_market procedure should be called with the (query) information contained in the verification link.

  • Procedure: xbr.network.join_market

  • Errors: wamp.error.*

See also

Unit test test_api06_market.py

Parameters:
  • member_id – ID of the member that joins

  • market_id – ID of the market to join.

  • chain_id – Verifying blockchain ID.

  • block_number – Current block number,

  • contract_adr – Verifying contract address.

  • actor_type – Type of actor to join under (PROVIDER = 3, CONSUMER = 4).

  • meta_hash

    Multihash (SHA256 Base64-encoded, for example "QmcU74QYcPQJCPUVVRwguVfrSnt8ZJrnbXzYPhxfhey7Qb") computed from a CBOR-serialized metadata object:

    {
    }
    

  • meta_data – CBOR-serialized metadata object (see above).

  • signature – EIP712 signature (using private key of member) over chain_id, block_number, contract_adr, market_id, actor_type and meta_hash.

  • details (autobahn.wamp.types.CallDetails) – Caller details.

Returns:

async login_member(member_email: str, client_pubkey: bytes, chain_id: int, block_number: int, contract_adr: bytes, timestamp: int, wallet_adr: bytes, signature: bytes, details: autobahn.wamp.types.CallDetails | None = None) dict[source]

When a user is already member in the XBR network, a user client may call this procedure to login.

Adds a (WAMP-cryptosign) client public key for the XBR member. The signature must be created using the private key of the members’ wallet.

For example, on a new browser instance, a user might install Metamask and provide the seedphrase of the users existing wallet. The client now creates a new Ed25519 private key (for WAMP-cryptosign). Then, by using Metamask for signing data and calling this procedure, the user will receive a verification email with a verification code. The client then needs to call Api.verify_login_member() with the verification action ID and code received via email. This latter procedure will then add the user client key to the authentication database of the XBR Network backend.

  • Procedure: xbr.network.login_member

  • Errors: wamp.error.*

See also

Unit test test_api03_login.py

Parameters:
  • member_email – Existing member (primary) email address.

  • client_pubkey – Client Ed25519 public key (32 bytes).

  • chain_id – Blockchain ID.

  • block_number – Blockchain current block number.

  • contract_adr – Address of XBRNetwork smart contract.

  • timestamp – Timestamp of submission (number of nanoseconds since the Unix epoch within the client).

  • wallet_adr – Member wallet address used for signing.

  • signature – EIP712 signature (using wallet private key of member) over member_email, client_pubkey, chain_id, block_number, contract_adr and timestamp.

  • details (autobahn.wamp.types.CallDetails) – Caller details.

Returns:

Verification submission, including verification action ID. For example:

{
    "timestamp": 1573675753141788247,
    "action": "login-member",
    "vaction_oid": b'ŸUWØ7øD`ŒªK—ÿ ¾'
}
  • timestamp: Timestamp of submission (number of nanoseconds since the Unix epoch).

  • action: Type of action being verified, eg "login-member"

  • vaction_oid: ID of action verified (16 bytes UUID).

async logout_member(details: autobahn.wamp.types.CallDetails)[source]

Logout the currently authenticated authid and delete the (WAMP-cryptosign) client public key from the member.

Note

The procedure will return normally, but then immediately kill the client session pro-actively from the router-side.

See also

Unit test test_api03_logout.py

Parameters:

details (autobahn.wamp.types.CallDetails) – Caller details.

Returns:

Client key removed information.

async onJoin(details)[source]

Implements autobahn.wamp.interfaces.ISession.onJoin()

onLeave(details)[source]

Implements autobahn.wamp.interfaces.ISession.onLeave()

async onboard_member(member_username: str, member_email: str, client_pubkey: bytes, wallet_type: str, wallet_adr: bytes, chain_id: int, block_number: int, contract_adr: bytes, eula_hash: str, profile_hash: str | None, profile_data: bytes | None, signature: bytes, details: autobahn.wamp.types.CallDetails | None = None) dict[source]

On-board new member with the given information. If all is fine with the supplied information, the member will be sent a verification email to the email address specified.

Once the Web link contained in the verification email is clicked, the xbrnetwork.Api.verify_onboard_member procedure should be called with the (query) information contained in the verification link.

  • Procedure: xbr.network.onboard_member

  • Errors: wamp.error.*

See also

Unit test test_api02_onboard.py

Parameters:
  • member_username – New member username. A username must begin with a lower-case letter, continue with lower-case letters, digits or _ and have a length from 4 to 14 characters.

  • member_email – New member email address.

  • client_pubkey – Client Ed25519 public key (32 bytes).

  • wallet_type – Wallet type.

  • wallet_adr – New member wallet address.

  • chain_id – Blockchain ID.

  • block_number – Current blockchain block number.

  • contract_adr – Address of XBRNetwork smart contract.

  • eula_hash – Multihash (sha256, base64 encoded) of XBR Network EULA signed (eg currently, the EULA multihash must be "QmV1eeDextSdUrRUQp9tUXF8SdvVeykaiwYLgrXHHVyULY").

  • profile_hash

    Multihash (SHA256 Base64-encoded, for example "QmcU74QYcPQJCPUVVRwguVfrSnt8ZJrnbXzYPhxfhey7Qb") computed from a CBOR-serialized profile object:

    {
        "member_username": member_username,
        "member_email": member_email,
        "client_pubkey": client_pubkey
        "wallet_type": wallet_type
    }
    

  • profile_data – CBOR-serialized profile object (see above).

  • signature – EIP712 signature (using wallet private key of member) over chain_id, block_number, contract_adr, eula_hash and profile_hash.

  • details (autobahn.wamp.types.CallDetails) – Caller details.

Returns:

Verification submission, including verification action ID. For example:

{
    "timestamp": 1573675753141788247,
    "action": "onboard-member",
    "vaction_oid": b'ŸUWØ7øD`ŒªK—ÿ ¾'
}
  • timestamp: Timestamp of submission (number of nanoseconds since the Unix epoch).

  • action: Type of action being verified, eg "onboard_member"

  • vaction_oid: ID of action verified (16 bytes UUID).

publish_api(member_oid: bytes, catalog_oid: bytes, api_oid: bytes, verifying_chain_id: int, current_block_number: int, verifying_contract_adr: bytes, schema_hash: str, schema_data: bytes, meta_hash: str | None, meta_data: bytes | None, signature: bytes, attributes: dict | None = None, details: autobahn.wamp.types.CallDetails | None = None) dict[source]

Publish an API to an existing XBR Data FbsRepository.

Parameters:
  • member_oid – OID of the member to create the catalog under (the member will become catalog owner.).

  • catalog_oid – OID of the (existing) catalog to publish the API to.

  • api_oid – OID of the new API (as published in the catalog).

  • verifying_chain_id – Blockchain ID.

  • current_block_number – Blockchain current block number.

  • verifying_contract_adr – Address of XBRNetwork smart contract.

  • schema_hash – Multihash for XBR/WAMP Flatbuffers based API schema.

  • schema_data – Serialized binary XBR/WAMP Flatbuffers API schema. This is the schema file contents (.bfbs) produced by the flatc compiler.

  • meta_hash – Multihash for optional off-chain API meta-data.

  • meta_data – Optional off-chain API meta-data.

  • attributes – Object standard attributes like title, description and tags.

  • signature – EIP712 signature for the catalog market creation.

  • details (autobahn.wamp.types.CallDetails) – Caller details.

Returns:

API creation information.

recover_wallet(member_email: str, chain_id: int, block_number: int, contract_adr: bytes, req_nonce: int, wallet_adr: bytes, signature: bytes, details: autobahn.wamp.types.CallDetails | None = None) dict[source]

Recover a hosted wallet (account wallet_type == "hosted")

Parameters:
  • member_email – Existing member (primary) email address.

  • chain_id – Blockchain ID.

  • block_number – Blockchain current block number.

  • contract_adr – Address of XBRNetwork smart contract.

  • req_nonce – Random request nonce (chosen by client).

  • wallet_adr – Member wallet address used for signing.

  • signature – EIP712 signature (using wallet private key of member) over member_email, chain_id, block_number, contract_adr and req_nonce.

Returns:

Wallet recovery submission, including verification action ID and code. For example:

{
    "now": 1573675753141788247,
    "valid_until": 1573675753971231455,
    "vaction": "recover-wallet",
    "vaction_oid": "9f5557d8-37f8-4460-8c90-aa4b97ffa0be",
    "vaction_code": "PXFH-GF4Y-7ALJ"
}

remove_catalog(member_oid: bytes, chain_id: int, block_number: int, contract_adr: bytes, signature: bytes, details: autobahn.wamp.types.CallDetails | None = None)[source]

Remove an existing XBR Data FbsRepository.

Parameters:
  • member_oid – ID of the member to remove the data market under (must be owner).

  • chain_id – Blockchain ID.

  • block_number – Blockchain current block number.

  • contract_adr – Address of XBRNetwork smart contract.

  • signature – EIP712 signature (computed over the fields chain_id, block_number, contract_adr, …) for the data market removal.

  • details (autobahn.wamp.types.CallDetails) – Caller details.

Returns:

Data catalog removal information.

remove_domain(member_oid: bytes, chain_id: int, block_number: int, contract_adr: bytes, signature: bytes, details: autobahn.wamp.types.CallDetails | None = None)[source]

Remove an existing XBR Cloud Domain.

Parameters:
  • member_oid – ID of the member to remove the cloud domain under (must be owner).

  • chain_id – Blockchain ID.

  • block_number – Blockchain current block number.

  • contract_adr – Address of XBRNetwork smart contract.

  • signature – EIP712 signature (computed over the fields chain_id, block_number, contract_adr, …) for the cloud domain removal.

  • details (autobahn.wamp.types.CallDetails) – Caller details.

Returns:

Cloud domain removal information.

remove_market(member_oid: bytes, chain_id: int, block_number: int, contract_adr: bytes, market_adr: bytes, signature: bytes, details: autobahn.wamp.types.CallDetails | None = None) dict[source]

Remove an existing XBR Data Market. The caller of this procedure must be the owner of the market, and all the market must be fully cleared first.

Parameters:
  • member_oid – ID of the member to remove the data market under (must be owner).

  • chain_id – Blockchain ID.

  • block_number – Blockchain current block number.

  • contract_adr – Address of XBRNetwork smart contract.

  • market_adr – Address of market to remove (the address of the respective XBRMarket smart contract).

  • signature – EIP712 signature (computed over the fields chain_id, block_number, contract_adr, …) for the data market removal.

  • details (autobahn.wamp.types.CallDetails) – Caller details.

Returns:

Data market removal information.

update_market(market_oid: bytes, attributes: dict | None, details: autobahn.wamp.types.CallDetails | None = None)[source]

Update off-chain information attached to market, such as attributes.

Parameters:
  • market_oid – OID of the XBR Data Market to update information for.

  • attributes – If provided, should be a mapping of names of attributes to update mapped to the new values (to set or modify) or to the value None to remove the attribute.

  • details (autobahn.wamp.types.CallDetails) – Caller details.

async verify_create_catalog(vaction_oid: bytes, vaction_code: str, details: autobahn.wamp.types.CallDetails | None = None) dict[source]

Verify creating a new data API catalog by submitting a verification code.

Upon successful catalog creation, this procedure will also publish the same data that is returned to the following topic:

  • Procedure: xbr.network.verify_create_catalog

  • Events: xbr.network.on_new_catalog

  • Errors: wamp.error.*

See also

Unit test fixme.py

Parameters:
  • vaction_oid – Verification action ID (16 bytes UUID).

  • vaction_code – Verification code, for example "EK5H-JJ4H-CECK"

  • details (autobahn.wamp.types.CallDetails) – Caller details.

Returns:

FbsRepository creation information. For example:

{
    'created': 1582146264584727254,
    'catalog_oid': b'...',
    'block_hash': b'...',
    'block_number': b'...',
    'transaction_hash': b'...',
    'transaction_index': b'...'
}
  • created: FbsRepository creation timestamp (number of nanoseconds since the Unix epoch).

  • catalog_oid: ID of newly created catalog (16 bytes UUID).

async verify_create_coin(vaction_oid: bytes, vaction_code: str, details: autobahn.wamp.types.CallDetails | None = None) dict[source]

Verify creating a new ERC20 coin by submitting a verification code.

Upon successful coin creation, this procedure will also publish the same data that is returned to the following topic:

  • Procedure: xbr.network.verify_create_coin

  • Events: xbr.network.on_new_coin

  • Errors: wamp.error.*

Parameters:
  • vaction_oid – Verification action ID (16 bytes UUID).

  • vaction_code – Verification code, for example "EK5H-JJ4H-CECK"

  • details (autobahn.wamp.types.CallDetails) – Caller details.

Returns:

Coin creation information, including ID of new coin. For example:

{
    'created': 1582146264584727254,
    'market_oid': b'...',
    'block_hash': b'...',
    'block_number': b'...',
    'transaction_hash': b'...',
    'transaction_index': b'...'
}
  • created: Coin creation timestamp (number of nanoseconds since the Unix epoch).

  • market_oid: ID of newly created coin (16 bytes UUID).

async verify_create_market(vaction_oid: bytes, vaction_code: str, details: autobahn.wamp.types.CallDetails | None = None) dict[source]

Verify creating a new data market by submitting a verification code.

Upon successful market creation, this procedure will also publish the same data that is returned to the following topic:

  • Procedure: xbr.network.verify_create_market

  • Events: xbr.network.on_new_market

  • Errors: wamp.error.*

See also

Unit test test_api05_market.py

Parameters:
  • vaction_oid – Verification action ID (16 bytes UUID).

  • vaction_code – Verification code, for example "EK5H-JJ4H-CECK"

  • details (autobahn.wamp.types.CallDetails) – Caller details.

Returns:

Market creation information, including ID of new market. For example:

{
    'created': 1582146264584727254,
    'market_oid': b'...',
    'block_hash': b'...',
    'block_number': b'...',
    'transaction_hash': b'...',
    'transaction_index': b'...'
}
  • created: Market creation timestamp (number of nanoseconds since the Unix epoch).

  • market_oid: ID of newly created market (16 bytes UUID).

async verify_join_market(vaction_oid: bytes, vaction_code: str, details: autobahn.wamp.types.CallDetails | None = None) dict[source]

Verify joining a market by submitting a verification code.

  • Procedure: xbr.network.verify_join_market

  • Events: xbr.network.on_market_join

  • Errors: wamp.error.*

Note

This procedure will also publish the same data that is returned to the above topic.

See also

Unit test test_api06_market.py

Parameters:
Returns:

Market join information, including ID of existing market. For example:

{
    "member_oid": b'',
    "market_oid": b'',
    "roles": ["buyer", "seller"],
    "joined": 1573675753141788247,
}

async verify_login_member(vaction_oid: bytes, vaction_code: str, details: autobahn.wamp.types.CallDetails | None = None) dict[source]

Verify login of member by submitting a verification code.

Upon successful login, this procedure will also publish the same data that is returned to the following topic - but only for subscribers of same authid (clients of the user that was logged in):

  • Procedure: xbr.network.verify_login_member

  • Events: xbr.network.on_member_login

  • Errors: wamp.error.*

See also

Unit test test_api03_login.py

Parameters:
Returns:

Member login information, including ID of existing member. For example:

{
    "member_oid": None,
    "client_pubkey": None,
    "created": 1573675753141788247,
}

async verify_onboard_member(vaction_oid: bytes, vaction_code: str, details: autobahn.wamp.types.CallDetails | None = None) dict[source]

Verify on-boarding of a new member by submitting a verification code.

Upon successful on-board, this procedure will also publish the same data that is returned to the following topic - but only for subscribers of same authid (clients of the user that was on-boarded):

  • Procedure: xbr.network.verify_onboard_member

  • Events: xbr.network.on_new_member

  • Errors: wamp.error.*

See also

Unit test test_api02_onboard.py

Parameters:
  • vaction_oid – Verification action ID (16 bytes UUID).

  • vaction_code – Verification code, for example "EK5H-JJ4H-CECK"

  • details (autobahn.wamp.types.CallDetails) – Caller details.

Returns:

Member on-boarded information, including ID of new member. For example:

{
    'created': 1582146264584727254,
    'member_oid': b'...',
    'block_hash': b'...',
    'block_number': b'...',
    'transaction_hash': b'...',
    'transaction_index': b'...'
}
  • created: Member creation timestamp (number of nanoseconds since the Unix epoch).

  • member_oid: ID of newly on-boarded member (16 bytes UUID).

async verify_publish_api(vaction_oid: bytes, vaction_code: str, details: autobahn.wamp.types.CallDetails | None = None) dict[source]

Verify publishing an API to an API catalog by submitting a verification code.

Upon successful catalog creation, this procedure will also publish the same data that is returned to the following topic:

  • Procedure: xbr.network.verify_publish_api

  • Events: xbr.network.on_api_published

  • Errors: wamp.error.*

See also

Unit test fixme.py

Parameters:
  • vaction_oid – Verification action ID (16 bytes UUID).

  • vaction_code – Verification code, for example "EK5H-JJ4H-CECK"

  • details (autobahn.wamp.types.CallDetails) – Caller details.

Returns:

API publication information. For example:

{
    'published': 1582146264584727254,
    'member_oid': b'...',
    'catalog_oid': b'...',
    'api_oid': b'...',
    'block_hash': b'...',
    'block_number': b'...',
    'transaction_hash': b'...',
    'transaction_index': b'...'
}
  • published: API publication timestamp (number of nanoseconds since the Unix epoch).

  • api_oid: OID of newly published API (16 bytes UUID).

verify_recover_wallet(vaction_oid: bytes, vaction_code: str, details: autobahn.wamp.types.CallDetails | None = None) bytes[source]

Verify recovery of a (hosted) wallet the member by submitting a verification code.

Parameters:
Returns:

The serialized wallet data (encrypted with a password).