Stablecoin 链码包

Oracle Blockchain Platform Digital Assets Edition 包含稳定币生命周期场景的示例链代码。

稳定币链代码支持稳定币的完整生命周期,以基于扩展代币分类框架标准的可替换代币表示。您可以使用链代码方法通过基于角色的审批来制作、转移、持有和刻录令牌。

可从 Oracle Blockchain Platform 控制台下载稳定币链代码包,其中包括以下组件。
  • Stablecoin.zip,包含用于部署的打包链代码的归档文件。
  • Stablecoin.yaml,一个规范文件,可以与区块链应用程序构建器一起使用来支架 Stablecoin 链代码。
  • Stablecoin_postman_collection.json,一个 Postman 集合,用于测试链代码中的 API。
  • README.md 是使用链代码的分步指南。

要获取稳定币链代码包,请在 Oracle Blockchain Platform Digital Assets 控制台中单击 Digital Assets(数字资产)选项卡,然后选择 Stablecoin Application(稳定币应用程序)

规范文件

稳定币规范文件 (Stablecoin.yml) 基于扩展的令牌分类框架规范文件。除了 stablecoin 资产之外,规范文件还定义了 AccountPolicyCheckApprovalPolicyCheckApprovalTransactions 资产。
#
# Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. 
#

assets:

# Token asset to manage the complete lifecycle of stablecoin

    - name: stablecoin # Asset name
      type: token # Asset type
      standard: ttf+   # Token standard

      anatomy:
          type: fungible # Token type 
          unit: fractional # Token unit

      behavior: # Token behaviors
          - divisible:
                decimal: 2 
          - mintable: 
                mint_approval_required: true  
          - transferable 
          - burnable:
                burn_approval_required: true 
          - holdable
          - roles:
                minter_role_name: minter
                burner_role_name: burner
                notary_role_name: notary
                mint_approver_role_name: notary
                burn_approver_role_name: notary 

      properties: # Custom asset attributes for stablecoin

          - name: currencyName # The currency name that the stablecoin is pegged with
            type: string
            mandatory: true

          - name: conversionRate # The currency to stablecoin conversion rate
            type: float
            mandatory: true

# Generic asset to maintain the account policy and approval policy details

    - name: AccountPolicyCheck # Asset name

      properties: # Asset attributes 

          - name: accountPolicyId
            type: string
            mandatory: true
            id: true
            derived:
              strategy: concat
              format: ["APID~%1~%2","orgId","userId"]

          - name: orgId
            type: string
            mandatory: true
            validate: required()

          - name: userId
            type: string
            mandatory: true
            validate: required()

          - name: kycCompliance  
            type: string
            validate: /^\s*(true|false)\s*$/
            mandatory: true            

          - name: amlCompliance 
            type: string
            validate: /^\s*(true|false)\s*$/
            mandatory: true

          - name: riskScore 
            type: float
            validate: min(0)

          - name: restrictionFlag 
            type: string
            validate: /^\s*(true|false)\s*$/ 
            mandatory: true

      methods:
          crud: [create, update, getById, delete]
          others: [getHistoryById, getByRange]  

    - name: ApprovalPolicyCheck # Asset name
      
      properties: # Asset attributes 

          - name: approvalPolicyId
            type: string
            mandatory: true
            id: true
            derived:
              strategy: concat
              format: ["GPID~%1~%2","transactionLowerLimit","transactionUpperLimit"]

          - name: transactionLowerLimit
            type: string
            validate: required()

          - name: transactionUpperLimit
            type: string
            validate: required()

          - name: numberOfApprovalsRequired
            type: number
            mandatory: true
            validate: min(0)

          - name: approverDetails
            type: approverDetails[]
 

      methods:
          crud: [create, update, getById, delete]
          others: [getHistoryById, getByRange]    

    - name: approverDetails # Asset name
      type: embedded
      properties: # Asset attributes 

          - name: approverOrgId  
            type: string
            mandatory: true
            validate: required()

          - name: approverUserId  
            type: string
            mandatory: true
            validate: required()

          - name: approvalSequence  
            type: number
            mandatory: true
            validate: positive()

    - name: ApprovalTransactions # Asset name
      
      properties: # Asset attributes 

          - name: approvalTransactionId
            type: string
            mandatory: true
            id: true
            derived:
              strategy: concat
              format: ["%1~%2","approvalOperationId","approverAccountId"]

          - name: approvalOperationId
            type: string
            mandatory: true

          - name: fromAccountId
            type: string  
            mandatory: true

          - name: toAccountId
            type: string
            mandatory: true

          - name: approverAccountId
            type: string
            mandatory: true   

          - name: totalApprovals
            type: number 
            mandatory: true 
            validate: min(0)

          - name: timestamp
            type: string 
            mandatory: true             

      methods:
          crud: [getById ]
          others: []
          
customMethods:

  - "getApproverDetailsByTransferAmount(Amount: number)" # Customized method for fetching approver details