> ## Documentation Index
> Fetch the complete documentation index at: https://rain-sandbox-trial.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Onramp to Rain Contract

> Enable virtual accounts for users to onramp fiat funds into their Rain smart contracts using ACH, RTP, and wire transfers.

<Warning>
  **Limited: Rain-Managed programs only**

  This onramping feature is available for Rain-Managed programs only. Partner-Managed tenants can use the Onramping feature directly from the Rain dashboard.
</Warning>

## Before you begin

Make sure you have:

* **US bank account:** this is where the user's or company's funds originate from.
* **Rain collateral contracts:** automatically deployed when a user's or company's compliance status is `Approved` under a Rain-Managed program.
* **API keys:** you need access to the `contracts` endpoints to enable this feature.

### Compliance data requirements

Enabling onramp requires the user or company to have completed verification:
Rain sends their verified identity data (name and date of birth for consumers,
company name for companies) to the banking provider when it provisions the
virtual account. A contract whose customer hasn't been through verification,
or that isn't associated with a customer, can't enable onramp — the API
returns a `400` such as `Contract has no associated team`, and a chain the
provider doesn't support returns `400 Unsupported chain ID`.

## Enable onramping

Enabling Rain's onramp feature means generating unique ACH, RTP, and wire transfer details on your user's smart contract.

### API flow

When a user wants to onramp fiat into their smart contract, you need to enable the onramp feature on their contract and provide them with dedicated banking credentials. Any funds sent to these credentials are automatically converted to stablecoin and deposited into their smart contract.

<div className="wf-diagram">
  <div className="legend">
    <span className="lg"><span className="swatch action" />Action / step</span>
  </div>

  <div className="diagram-shell borderless">
    <svg id="onramp-contract-flow" role="img" aria-label="Onramp to Rain contract: the user requests account details, the partner retrieves the user's collateral contracts, enables onramp on one, retrieves it again for the generated virtual account details, and provides ACH, RTP, or wire info to the user." viewBox="0 0 1080 976" width="1080" height="976" style={{width: "100%", height: "auto"}}><defs><marker id="arrow-onramp-contract-flow" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" className="marker-fill-default" /></marker></defs><path d="M 540 164 L 540 204" fill="none" className="conn-default" stroke-width="1.7" marker-end="url(#arrow-onramp-contract-flow)" opacity="0.92" /><path d="M 540 272 L 540 312" fill="none" className="conn-default" stroke-width="1.7" marker-end="url(#arrow-onramp-contract-flow)" opacity="0.92" /><path d="M 540 380 L 540 420" fill="none" className="conn-default" stroke-width="1.7" marker-end="url(#arrow-onramp-contract-flow)" opacity="0.92" /><path d="M 540 488 L 540 528" fill="none" className="conn-default" stroke-width="1.7" marker-end="url(#arrow-onramp-contract-flow)" opacity="0.92" /><path d="M 540 596 L 540 636" fill="none" className="conn-default" stroke-width="1.7" marker-end="url(#arrow-onramp-contract-flow)" opacity="0.92" /><path d="M 540 704 L 540 744" fill="none" className="conn-default" stroke-width="1.7" marker-end="url(#arrow-onramp-contract-flow)" opacity="0.92" /><path d="M 540 812 L 540 852" fill="none" className="conn-default" stroke-width="1.7" marker-end="url(#arrow-onramp-contract-flow)" opacity="0.92" /><foreignObject x="320" y="96" width="440" height="68"><div className="card action"><span className="ct"><span className="tag">User</span><span className="lab">Gets account details</span></span></div></foreignObject><foreignObject x="320" y="204" width="440" height="68"><div className="card action"><span className="bn">1</span><span className="ct"><span className="tag">Partner</span><span className="lab">Gets the user's smart contract</span></span></div></foreignObject><foreignObject x="320" y="312" width="440" height="68"><div className="card action"><span className="bn">2</span><span className="ct"><span className="tag rain">Rain</span><span className="lab">Returns collateral contracts</span></span></div></foreignObject><foreignObject x="320" y="420" width="440" height="68"><div className="card action"><span className="bn">3</span><span className="ct"><span className="tag">Partner</span><span className="lab">Enables onramp on the contract</span></span></div></foreignObject><foreignObject x="320" y="528" width="440" height="68"><div className="card action"><span className="ct"><span className="tag rain">Rain</span><span className="lab">Accepted</span></span></div></foreignObject><foreignObject x="320" y="636" width="440" height="68"><div className="card action"><span className="bn">4</span><span className="ct"><span className="tag">Partner</span><span className="lab">Gets the contract again</span></span></div></foreignObject><foreignObject x="320" y="744" width="440" height="68"><div className="card action"><span className="ct"><span className="tag rain">Rain</span><span className="lab">Returns virtual account details</span></span></div></foreignObject><foreignObject x="320" y="852" width="440" height="68"><div className="card action"><span className="bn">5</span><span className="ct"><span className="tag">Partner</span><span className="lab">Provides ACH/RTP/wire info</span></span></div></foreignObject></svg>
  </div>
</div>

The steps above, in text:

| # | Actor   | Step                                                |
| - | ------- | --------------------------------------------------- |
| – | User    | Requests account details from the partner           |
| 1 | Partner | Gets the user's smart contract details              |
| 2 | Rain    | Returns the available collateral contracts          |
| 3 | Partner | Enables the onramp feature on the chosen contract   |
| – | Rain    | Accepts the update                                  |
| 4 | Partner | Gets the user's smart contract again                |
| – | Rain    | Returns the generated virtual account details       |
| 5 | Partner | Provides the ACH, RTP, and wire details to the user |

### Steps to enable onramping

You need to call these API endpoints synchronously to get the virtual account details for a user or company.

<Steps>
  <Step title="Get the user's smart contract">
    Call [Get smart contract information for a user](/reference/contracts/get-smart-contract-information-for-a-user) with the `userId` or `companyId` of the entity requesting to transfer. This returns the entity's available contracts from their respective chains. Use the `contractId` for the contract the entity intends to fund.
  </Step>

  <Step title="Enable the onramp feature">
    Call [Update a smart contract](/reference/contracts/update-a-smart-contract) to enable the **Onramp** feature. Once the operation completes, this returns an `Accepted` response body.
  </Step>

  <Step title="Retrieve the generated virtual account">
    Call [Get smart contract information for a user](/reference/contracts/get-smart-contract-information-for-a-user) again with the same `userId` or `companyId`. The `contract` object now contains the generated `onramp` account details the entity uses to fund the contract.

    ```json title="Sample response" theme={null}
    [
      {
        "id": "86ce05e5-62e3-48d6-bf37-473af62d9361",
        "chainId": 84532,
        "controllerAddress": "0x54d02DcB38B76A67dC9368D8457D1F384B865c70",
        "proxyAddress": "0x92dAaFeAe887d45a52D2AB4FD74aEc3Bf9Ab6A78",
        "depositAddress": "0x92dAaFeAe887d45a52D2AB4FD74aEc3Bf9Ab6A78",
        "tokens": [
          {
            "address": "0x29684075a3C86ea11D9964BcAf0F956e801396bD",
            "balance": "0.0",
            "exchangeRate": 1,
            "advanceRate": 100
          },
          {
            "address": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
            "balance": "0.0",
            "exchangeRate": 1,
            "advanceRate": 100
          },
          {
            "address": "0x10b5Be494C2962A7B318aFB63f0Ee30b959D000b",
            "balance": "0.0",
            "exchangeRate": 1,
            "advanceRate": 100
          }
        ],
        "contractVersion": 2,
        "onramp": {
          "ach": {
            "beneficiaryName": "JOHN DOE",
            "beneficiaryAddress": "123 Main St, Austin, TX, 78701",
            "beneficiaryBankName": "Partner Bank, N.A.",
            "beneficiaryBankAddress": "123 Bank St, New York, NY, 10038",
            "accountNumber": "0788752697",
            "routingNumber": "021110021"
          },
          "rtp": {
            "beneficiaryName": "JOHN DOE",
            "beneficiaryAddress": "123 Main St, Austin, TX, 78701",
            "beneficiaryBankName": "Metropolitan Commercial Bank, N.A.",
            "beneficiaryBankAddress": "456 Bank St, New York, NY, 10038",
            "accountNumber": "0777752697",
            "routingNumber": "021000021"
          },
          "wire": {
            "beneficiaryName": "JOHN DOE",
            "beneficiaryAddress": "123 Main St, Austin, TX, 78701",
            "beneficiaryBankName": "Cross River Bank, N.A.",
            "beneficiaryBankAddress": "321 Bank St, New York, NY, 10038",
            "accountNumber": "0777777697",
            "routingNumber": "021000021"
          }
        }
      }
    ]
    ```
  </Step>
</Steps>

## What happens when funds are received

Once you provide the virtual account details to your user, they can initiate a transfer from their US bank account using any of the three available rails:

* **ACH:** funds typically appear within 1-3 business days.
* **RTP:** funds typically appear within minutes.
* **Wire:** funds typically appear within minutes.

The funds are automatically converted to stablecoin and deposited into their Rain collateral contract.

## What's next

<Card title="Onramps" href="/docs/onramps">
  If you don't need funds delivered into a specific collateral contract, use
  the general payment-routes onramp flow instead.
</Card>

<Card title="Withdraw collateral" href="/docs/withdraw-collateral">
  Move stablecoin back out of a Rain collateral contract.
</Card>

<Card title="Review Rain-Managed programs" href="/docs/rain-managed-programs">
  Understand the requirements and constraints of a Rain-Managed program.
</Card>

<Card title="Review payments compliance" href="/docs/payments-compliance">
  See how Rain verifies account owners and screens transactions.
</Card>
