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

# CrossmintEmbeddedOfframp

> Swift Structure

**Structure**

A view that runs one Crossmint offramp session.

```swift theme={null}
@MainActor struct CrossmintEmbeddedOfframp
```

The user adds a bank account, gets a quote, verifies their identity when the session needs it, and confirms one deposit that the payer signs and sends. The view then follows the payout.
The Crossmint environment comes from the API key. Attach event handlers with `onReady(_:)`, `onStatusChange(_:)`, `onComplete(_:)`, `onCancel(_:)`, and `onError(_:)`.
The view takes the height of the page, unless `fill` is `true`. A change to the credentials, the appearance, the locale, `fill`, or to whether the payer has `signMessage` reloads the page. The payer and the handlers can change without a reload.
Identity verification uses the camera. Add `NSCameraUsageDescription` to your app’s Info.plist.

```swift theme={null}
CrossmintEmbeddedOfframp(
    apiKey: "ck_production_...",
    credentials: EmbeddedOfframpCredentials(sessionId: sessionId, clientSecret: clientSecret),
    payer: EmbeddedOfframpPayer(signAndSendTransaction: { transaction in
        try await wallet.signAndSend(transaction.serializedTransaction, on: transaction.chain)
    })
)
.onComplete { completion in print("Deposit sent: \(completion.txId)") }
.onCancel { dismiss() }
```

## Initializers

### init(apiKey:credentials:payer:appearance:locale:fill:consoleLogLevel:)

Creates an offramp view.

```swift theme={null}
@MainActor init(apiKey: String, credentials: EmbeddedOfframpCredentials, payer: EmbeddedOfframpPayer, appearance: CheckoutAppearance? = nil, locale: CheckoutLocale? = nil, fill: Bool = false, consoleLogLevel: CheckoutLogLevel = .error)
```

#### Parameters

| Parameter | Description |
| - | - |
| `apiKey` | Your client-side API key. The key starts with `ck_`. |
| `credentials` | The credentials of the offramp session. |
| `payer` | Signs and sends the deposit from your wallet. |
| `appearance` | The visual customization. A `nil` value keeps the offramp defaults. |
| `locale` | The language of the screens. A `nil` value uses the device language, else English. |
| `fill` | Fills the height that the layout gives the view instead of taking the height of the page. |
| `consoleLogLevel` | The minimum level of the SDK messages that reach the system console. |

## Instance Properties

| Property | Type | Description |
| - | - | - |
| `body` | `some View` | Inherited from `View.body`. |

## Instance Methods

### onCancel(\_:)

Adds an action to perform when the user closes the flow. Without it, the Continue, Close, and Cancel buttons do nothing.

```swift theme={null}
@MainActor func onCancel(_ action: @escaping () -> Void) -> CrossmintEmbeddedOfframp
```

### onComplete(\_:)

Adds an action to perform when the deposit is confirmed. It can run again for a reopened withdrawal, so deduplicate by `orderId`.

```swift theme={null}
@MainActor func onComplete(_ action: @escaping (OfframpCompletion) -> Void) -> CrossmintEmbeddedOfframp
```

### onError(\_:)

Adds an action to perform when something goes wrong. `retriable` shows if a new attempt can work.

```swift theme={null}
@MainActor func onError(_ action: @escaping (OfframpError) -> Void) -> CrossmintEmbeddedOfframp
```

### onReady(\_:)

Adds an action to perform when the first screen shows. It runs once per load.

```swift theme={null}
@MainActor func onReady(_ action: @escaping () -> Void) -> CrossmintEmbeddedOfframp
```

### onStatusChange(\_:)

Adds an action to perform when the flow moves to another step.

```swift theme={null}
@MainActor func onStatusChange(_ action: @escaping (OfframpStatusChange) -> Void) -> CrossmintEmbeddedOfframp
```
