Wrapper APIs
The enhanced version of Blockchain App Builder can generate wrapper APIs for API Gateway, which support dedicated endpoints for each chaincode method.
A wrapper API is an abstraction layer over an Oracle Blockchain Platform endpoint. Wrapper APIs support configuring common parameters and API-specific endpoint names, which can simplify usage and clarity.
In the base version of Oracle Blockchain Platform, an API endpoint requires parameters including the chaincode name, timeout and sync values, arguments (including the method name), channel name, and instance URL. These parameters must be passed with every invocation. Because most of these parameters are common to all methods, you can use the wrapper API functionality to create an endpoint for each method, which you then invoke using only the method parameters. Instead of a common endpoint, either a transaction or a query, you can have a custom endpoint name for each method. Whereas API endpoints in Oracle Blockchain Platform use POST requests, wrapper APIs support both POST and GET requests. You can also add an extra layer of authentication with wrapper APIs by using the API Gateway authentication mechanism.
The following example shows the createAccount method API in Oracle Blockchain Platform.
Endpoint: https://blockchain.example.com:7443/restproxy/api/v2/channels/default/transactions
{
"chaincode": "{{bc-chaincode-name}}",
"args": [
"createAccount",
"{{bc-org-id}}",
"{{bc-user-id}}",
"fungible",
"{\"max_daily_amount\":10000,\"max_daily_transactions\":100}"
],
"timeout": {{bc-timeout}},
"sync": {{bc-sync}}
}
If you configure wrapper APIs, you can make the same method call as shown in the following example.
Endpoint: https://apigateway.example.com/appbuilder/createAccount
{
"orgId": "{{bc-org-id}}",
"userId": "user1",
"tokenType": "fungible",
"dailyLimits": "{\"max_daily_amount\":10000,\"max_daily_transactions\":100}",
}