> ## Documentation Index
> Fetch the complete documentation index at: https://www.helius.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 机密法币入场和出场

> 直接从私密余额进行法币的入场和出场，无需透露资产或金额。

用户可以直接对他们的机密 Solana 余额进行法币的入场和出场。
这两个操作都不涉及公共余额，因此不会透露用户入场或出场的资产或金额。

<Tabs>
  <Tab title="从法币余额入场">
    | Field                    | Visibility  | Why                                                                   |
    | ------------------------ | ----------- | --------------------------------------------------------------------- |
    | Fiat balance and payment | Not onchain | The fiat payment is not onchain                                       |
    | Asset                    | Private     | The asset is encrypted onchain                                        |
    | Amount                   | Private     | The transferred amount is encrypted onchain                           |
    | Onramp Provider          | Public      | In a confidential Ring the wallet address of the provider is visible. |
    | User wallet address      | Public      | In a confidential Ring the user wallet address is visible onchain.    |
  </Tab>

  <Tab title="到法币余额出场">
    | Field               | Visibility  | Why                                                                   |
    | ------------------- | ----------- | --------------------------------------------------------------------- |
    | Fiat payout         | Not onchain | The fiat payout is not onchain                                        |
    | Asset               | Private     | The asset is encrypted onchain                                        |
    | Amount              | Private     | The transferred amount is encrypted onchain                           |
    | Offramp Provider    | Public      | In a confidential Ring the wallet address of the provider is visible. |
    | User wallet address | Public      | In a confidential Ring the user wallet address is visible onchain.    |
  </Tab>
</Tabs>

<img src="https://mintcdn.com/helius/q7LsEOD0O5LZhnha/images/privacy/on-off-ramp/on-offramp-overview.svg?fit=max&auto=format&n=q7LsEOD0O5LZhnha&q=85&s=5678250e0ea926b6461a4c09e2fa5886" alt="法币入场和出场。在法币侧，一个用户法币余额框通过双向箭头连接到Onramp Provider和Offramp Provider圆圈，该圆圈跨越法币和链上的虚线分隔。在私人链侧，供应商通过双向箭头连接到持有私人余额的用户钱包。" width="1560" height="500" data-path="images/privacy/on-off-ramp/on-offramp-overview.svg" />

## 前提条件：

* 提供者（例如，中心化交易所或法币到加密处理器）持有资产的私密余额以供私密入场和出场（SOL或任何SPL / Token 2022代币，如USDC）。
* 确保私密入场和出场账户有足够的余额以服务您的用户。
* 用户拥有一个私密钱包。

## 高级流程

法币部分取决于您的内部账本。
私密入场和出场可以集成到默认环或自定义环中。自定义环可以是机密或匿名的。

### 1. 入场

入场为私密余额充值：用户在链下支付法币；提供者从其入场账户向用户的私密钱包发送链上私密转账。

1. 用户存入法币。
2. 提供者在内部账本中将用户的法币存款匹配到一个私密钱包。
3. 提供者同步入场账户的私密余额以获取其最新余额，然后向用户的私密钱包发送私密转账。

```mermaid theme={"system"}
%%{init: {
  'theme': 'base',
  'themeVariables': {
    'lineColor':           '#FF6B35',
    'primaryTextColor':    '#737373',
    'primaryBorderColor':  '#9CA3AF',
    'actorBkg':            '#FFFFFF',
    'actorBorder':         '#9CA3AF',
    'actorTextColor':      '#737373',
    'signalColor':         '#FF6B35',
    'signalTextColor':     '#737373',
    'labelBoxBkgColor':    '#FF6B351F',
    'labelBoxBorderColor': '#FF6B35',
    'noteBkgColor':        '#F5F5F5',
    'noteTextColor':       '#737373',
    'noteBorderColor':     '#9CA3AF'
  }
}}%%
sequenceDiagram
    participant User
    participant UW as UserWallet
    participant P as Provider OnOfframp
    participant RPC as RPC
    participant SPP as Solana

    User->>P: onramp request (fiat amount)

    P->>RPC: sync the on-ramp account balance
    RPC-->>P: latest on-ramp account balance
    Note over P: build and sign the private transfer
    P->>RPC: request proof
    RPC-->>P: proof
    P->>SPP: submit private transfer (on-ramp account to user)
    SPP-->>P: confirmed, transaction hash

    UW->>RPC: sync private balance
    RPC-->>UW: confirm private balance
```

### 2. 出场

出场是从用户的私密钱包到出场账户的私密转账，并更新提供者的内部账本以支付法币给用户。

完成私密出场的步骤包括：

1. 用户同步其私密余额并向提供者的出场账户发送私密转账。
2. 在机密环中，提供者可以通过可见的用户钱包地址匹配转账。在匿名环中，公共账本不透露发件人或收件人；通过内部账本中的出场请求进行匹配。

```mermaid theme={"system"}
%%{init: {
  'theme': 'base',
  'themeVariables': {
    'lineColor':           '#FF6B35',
    'primaryTextColor':    '#737373',
    'primaryBorderColor':  '#9CA3AF',
    'actorBkg':            '#FFFFFF',
    'actorBorder':         '#9CA3AF',
    'actorTextColor':      '#737373',
    'signalColor':         '#FF6B35',
    'signalTextColor':     '#737373',
    'labelBoxBkgColor':    '#FF6B351F',
    'labelBoxBorderColor': '#FF6B35',
    'noteBkgColor':        '#F5F5F5',
    'noteTextColor':       '#737373',
    'noteBorderColor':     '#9CA3AF'
  }
}}%%
sequenceDiagram
    participant User
    participant UW as UserWallet
    participant P as Provider OnOfframp
    participant RPC as RPC
    participant SPP as Solana

    User->>P: send off-ramp request (amount)

    UW->>RPC: sync private balance
    Note over UW: build and sign the private transfer
    UW->>RPC: request proof
    RPC-->>UW: proof
    UW->>SPP: submit private transfer (user to off-ramp account)
    SPP-->>UW: confirmed, transaction hash

    P->>RPC: sync off-ramp account
    RPC-->>P: off-ramp request confirmed
    Note over P: match sender to a user, credit fiat ledger
    P->>User: pay out fiat
```

### 3. 入场和出场账户

入场和出场账户是提供者的私密余额，服务于用户的入场和出场。它可以持有您想支持的SOL或任何SPL或Token-2022代币，如USDC。

确保入场和出场账户有足够的余额以服务您的用户，类似于公共入场和出场。

#### 为入场和出场账户提供资金

要为账户的私密余额提供资金，从公共Solana余额（源公共钱包）存入私密余额。用户仅通过私密转账与账户交互，因此转给用户的金额和资产永远不会被暴露。

| Field                      | Visibility | Why                                                |
| -------------------------- | ---------- | -------------------------------------------------- |
| Source public wallet       | Public     | The source wallet address is visible onchain       |
| Asset                      | Public     | The asset is visible onchain                       |
| Amount                     | Public     | The deposited amount is visible onchain            |
| Destination wallet address | Public     | The destination wallet address is visible onchain  |
| Resulting private balance  | Private    | The resulting private balance is encrypted onchain |

## 开始集成

<Card title="原生钱包集成" icon="wallet" href="/docs/zh/privacy/integration/wallet">
  使用您自己的密钥管理添加隐私支持。适用于希望管理加密密钥并运行状态同步的提供者。
</Card>

<Card title="集成嵌入式隐私钱包" icon="key" href="/docs/zh/privacy/integration/embedded-wallet">
  通过REST API为您的应用添加隐私支持。适用于希望快速入门而无需自行进行密钥管理和状态同步的提供者和应用。
</Card>

<Card title="与自定义环集成" icon="building" href="/docs/zh/privacy/integration/enterprise">
  通过REST API添加隐私支持，并配置具有政策和合规控制的自定义环。
  适用于金融科技、工资平台、汇款公司、新型银行和企业。
</Card>

## Didn't find what you were looking for?

<Callout type="info">
  Reach out! [Telegram](https://t.me/tilo_light) | [E-Mail](mailto:sales@helius.xyz) | [Contact](https://www.helius.dev/contact)
</Callout>
