Oracle Database View Definitions for Wholesale CBDC

You can use the rich history database to retrieve account transaction history and resolve incorrect balances in multiple transactions that occur in the same block.

You can use the GetAccountTransactionHistoryWithFiltersFromRichHistDB API to fetch account transaction history from the rich history database. When you pass the custom_endpoint and bearer_token parameters to the method, the account transaction history is retrieved from the rich history database or the state database.
To retrieve transaction history from the rich history database, you must be running Oracle Autonomous Database with Oracle REST Data Services (ORDS) and OAuth enabled.
  1. Enable and configure the rich history database.
    For more information, see Enable and Configure the Rich History Database in Using Oracle Blockchain Platform.
  2. Enable rich history on the channels that contain the chaincode data that you want to write to the rich history database. For more information, see Configure the Channels that Write Data to the Rich History Database in Using Oracle Blockchain Platform.
  3. Download and install Node.js version 18 or later.
  4. On the Digital Assets page in Oracle Blockchain Platform, select Wholesale CBDC Application.
  5. Click Download the Database View Definitions package.
  6. Extract the WholesaleCBDCViewsPackage.zip file.
  7. Navigate to the ORDSscript folder and install the required dependencies by running the following command.
    npm install
  8. Edit the .env file that is supplied with the script to configure it for your environment.
    Oracle REST Data Services endpoints use the following general format.
    <base_URL>/<user_name>/<resource_link>
    Environment / Configuration Type Environment / Configuration Variables Description Example
    DB Connection CONNECTION_STRING The connection string for the database.
    CONNECTION_STRING="(description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)
    (host=adg.ap-sydney-1.example.com))(connect_data=
    (service_name=g536390e55ee33f4_db_high.adg.example.com))(security=(ssl_server_dn_match=yes)))"
    View Configuration VIEW_NAME The name of the view for displaying account transaction details. This can be any value that does not conflict with existing assets in the database. VIEW_NAME="viewTest"
    View Configuration CHAINCODE_NAME The name of the chaincode to fetch transaction details from in the rich history database. CHAINCODE_NAME="BondMarketplace"
    View Configuration INSTANCE_NAME The name of the instance where the chaincode is deployed. INSTANCE_NAME="BondMarketplace"
    View Configuration CHANNEL_NAME The name of the channel where the chaincode is deployed. CHANNEL_NAME="default"
    ORDS Endpoint Setup MODULE_NAME The name of the ORDS module to use. This can be any value that does not conflict with existing assets in the database. MODULE_NAME="demotest"
    ORDS Endpoint Setup BASE_PATH The base path of the ORDS URL. This can be any value that does not conflict with existing assets in the database. BASE_PATH="demotest"
    ORDS Endpoint Setup PATTERN The pattern name of the ORDS URL. This can be any value that does not conflict with existing assets in the database. PATTERN="accountTransactionDetails"
    ORDS Endpoint Setup ITEMS_PER_PAGE The number of items to display per page in the ORDS query results. This can be any value that does not conflict with existing assets in the database. ITEMS_PER_PAGE=120
    ORDS REST Endpoint ORDS_REST_BASE_URL The base URL of the ORDS REST endpoint of the database. ORDS_REST_BASE_URL="https://g536390e55ee33f4_db_high.adg.ap-sydney-1.example.com"
    Alias Configuration ALIAS_NAME The alias to use in place of a user name in the REST endpoint URL. This can be any value that does not conflict with existing assets in the database. ALIAS_NAME="demotestAlias"
    ORDS Role ROLE_NAME The ORDS role that is assigned to the user. This can be any value that does not conflict with existing assets in the database. ROLE_NAME="demotest_role"
    ORDS Privilege PRIVILEGE_NAME The ORDS privilege that is assigned to the user. This can be any value that does not conflict with existing assets in the database. PRIVILEGE_NAME="demotest_priv"
    ORDS Privilege LABEL A label for the ORDS privilege. This can be any value that does not conflict with existing assets in the database. LABEL="demotest_label"
    ORDS Privilege DESCRIPTION A description of the ORDS privilege. This can be any value that does not conflict with existing assets in the database. DESCRIPTION="demotest_description"
    OAuth Configuration CLIENT_NAME The client name to use for OAuth authentication with the ORDS REST endpoint. This can be any value that does not conflict with existing assets in the database. CLIENT_NAME="demotest_client"
    OAuth Configuration OWNER The owner name to use for OAuth authentication with the ORDS REST endpoint. This can be any value that does not conflict with existing assets in the database. OWNER="demotest"
    OAuth Configuration DESCRIPTION A description of the OAuth configuration. This can be any value that does not conflict with existing assets in the database. DESCRIPTION="demotest_description"
    OAuth Configuration SUPPORT_EMAIL The support email address for the OAuth configuration. This can be any value that does not conflict with existing assets in the database. SUPPORT_EMAIL="test@example.com"

    Analytics view names are included in the software code. The accounts view is ACCOUNTS_MOD. The transaction view is TRANSACTION_MOD. The accounts transaction view is ACCOUNTS_TRANSACTION_MOD.

  9. Run the ORDS script by using the following command.
    npm run start --username='<username>' --password='<password>'

    In this example, <username> and <password> are the credentials for the rich history database, which must have the necessary permissions to create the view and the ORDS endpoint. The user name and password must be enclosed in single quotes (') because of limitations in the bash interface.

    When the command runs, the following prompts are displayed.
    Do you want to create the View and ORDS Endpoint? (y/n)
    Enter y to create the view and endpoint. Enter n if you have already created the view and endpoint.
    Please select the language of your chaincode? (TS/GO)
    If you entered y previously, enter TS for TypeScript or GO for Go.
    Do you want to generate ORDS Endpoint URL and Bearer Token? (y/n)
    Enter y to generate the endpoint credentials. Otherwise, enter n.
You might see the following error.
Error: ORA-20049: Cannot alter the URL mapping while the schema is enabled. Try disabling the schema first.
This error occurs because the database schema is enabled and thus cannot be mapped to the different alias that is specified in the .env file.
To work around this behavior, complete the following steps.
  1. Use the same alias name that was used previously, or check the REST services in the database for the schema alias.
  2. Disable the database schema and run the script again. For more information, see Oracle REST Data Services (ORDS) : Using SQL Developer.