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.
- Extract the
Stablecoin.ziparchive file. - Import the
Stablecoinchaincode to the Blockchain App Builder extension in Visual Studio Code. - Edit the
.ochain.jsonfile to update the value of theconfigFileLocationkey to the path of theStablecoin.ymlspecification file. - Open a terminal window and navigate to the chaincode folder, and then run the following command.
npm install
Sample Process Flow for the Stablecoin Chaincode
A typical process flow using the stablecoin methods follows these basic steps.- Token administrators use the
initializeStablecoinTokenmethod to initialize the stablecoin, specifying values for the fixedcurrencyName(such as USD) andconversionRate. - Token administrators use the
createAccountandassociateTokenToAccountmethods to create token accounts and assign roles for all users, including approvers for multi-level approvals, minters, notaries, senders, and receivers. - Token administrators or organization administrators use the
createAccountPolicyCheckmethod to create account policies for all senders and receivers, and verify KYC, AML, and restriction flags. - Token administrators use the
createApprovalPolicyCheckmethod 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. - Token administrators use the
addRolemethod to assign roles such as minter, burner, and notary to accounts.
- The minter uses the
requestMintmethod to request approval to mint stablecoins. - The mint approver uses the
approveMintmethod to approve the minter's request. - The stablecoins are issued to the minter's account.
- A user initiates a transfer by using the
holdTokensmethod. - The system checks the
AccountPolicyCheckpolicy for compliance. If either thekycComplianceor theamlCompliancevalues are set tofalsefor the sender or receiver, the transfer does not occur. If therestrictionFlagvalue is set totruefor the sender or receiver, only the amount in the lowest range in the approval policy can be transferred. The transfer amount is matched againstApprovalPolicyCheckthresholds and the appropriate approvers with the defined sequences are applied to the transaction. - Approvers use the
approveTransactionmethod to review and authorize the transfer. The approvals occur based on the approver's sequence as defined in the approval policy. - After all approvals, the system notary (defined during the hold process) uses the
executeHoldTokensmethod to approve the transaction. The approved amount is transferred to the receiver's account.
kycCompliance, amlCompliance and restrictionFlag values for the sender and receiver are validated during all approvals that use the approveTransaction or executeHoldTokens methods.
- The burner uses the
requestBurnmethod to request approval to burn (destroy) stablecoins. - The burn approver uses the
approveBurnmethod to approve the burner's request. - The stablecoins are burned from the burner's account.
- Administrators and auditors can trace every mint, hold, transfer, multi-level approval, and burn operation by using the
getAccountTransactionHistoryandgetAccountTransactionHistoryWithFiltersmethods.