Deploy and Test Stablecoin Chaincode

You can deploy the chaincode directly from the Oracle Blockchain Platform console or by using Blockchain App Builder.

Deploying the Chaincode

Before you deploy the chaincode, create enrollment IDs for each token user and then map the token users to their respective enrollment IDs. Specify only one user for each enrollment. For more information about adding enrollments, see Add Enrollments to a REST Proxy in Using Oracle Blockchain Platform.

When you deploy the token chaincode, you must call the init method and pass the organization ID and user ID of the Token Admin user.

For information about deploying from the Oracle Blockchain Platform console, see Use Advanced Deployment in Using Oracle Blockchain Platform.

To deploy using Blockchain App Builder, complete the following steps.
  1. Extract the Stablecoin.zip archive file.
  2. Import the Stablecoin chaincode to the Blockchain App Builder extension in Visual Studio Code.
  3. Edit the .ochain.json file to update the value of the configFileLocation key to the path of the Stablecoin.yml specification file.
  4. Open a terminal window and navigate to the chaincode folder, and then run the following command.
    npm install
For more information about deploying using Blockchain App Builder, see Deploy Your Chaincode Using Visual Studio Code in Using Oracle Blockchain Platform.

Sample Process Flow for the Stablecoin Chaincode

A typical process flow using the stablecoin methods follows these basic steps.
Setup:
  1. Token administrators use the initializeStablecoinToken method to initialize the stablecoin, specifying values for the fixed currencyName (such as USD) and conversionRate.
  2. Token administrators use the createAccount and associateTokenToAccount methods to create token accounts and assign roles for all users, including approvers for multi-level approvals, minters, notaries, senders, and receivers.
  3. Token administrators or organization administrators use the createAccountPolicyCheck method to create account policies for all senders and receivers, and verify KYC, AML, and restriction flags.
  4. Token administrators use the createApprovalPolicyCheck method to define approval policies by specifying transaction thresholds, approval requirements such as the required number of approvals, and approver details with approval sequences for multi-level approvals.
  5. Token administrators use the addRole method to assign roles such as minter, burner, and notary to accounts.
Minting:
  1. The minter uses the requestMint method to request approval to mint stablecoins.
  2. The mint approver uses the approveMint method to approve the minter's request.
  3. The stablecoins are issued to the minter's account.
Holding and Transferring:
  1. A user initiates a transfer by using the holdTokens method.
  2. The system checks the AccountPolicyCheck policy for compliance. If either the kycCompliance or the amlCompliance values are set to false for the sender or receiver, the transfer does not occur. If the restrictionFlag value is set to true for the sender or receiver, only the amount in the lowest range in the approval policy can be transferred. The transfer amount is matched against ApprovalPolicyCheck thresholds and the appropriate approvers with the defined sequences are applied to the transaction.
  3. Approvers use the approveTransaction method to review and authorize the transfer. The approvals occur based on the approver's sequence as defined in the approval policy.
  4. After all approvals, the system notary (defined during the hold process) uses the executeHoldTokens method to approve the transaction. The approved amount is transferred to the receiver's account.
The kycCompliance, amlCompliance and restrictionFlag values for the sender and receiver are validated during all approvals that use the approveTransaction or executeHoldTokens methods.
Burning:
  1. The burner uses the requestBurn method to request approval to burn (destroy) stablecoins.
  2. The burn approver uses the approveBurn method to approve the burner's request.
  3. The stablecoins are burned from the burner's account.
Auditing:
  • Administrators and auditors can trace every mint, hold, transfer, multi-level approval, and burn operation by using the getAccountTransactionHistory and getAccountTransactionHistoryWithFilters methods.
For more details about using Postman collections, see the following topics in Blockchain App Builder for Oracle Blockchain Platform.