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

# Data Types & Objects

## UserProfile

Represents an authenticated user in the Dynamic system.

```swift theme={"system"}
public struct UserProfile {
    public let userId: String
    public let email: String?
    public let phoneNumber: String?
    // ... other properties
}
```

### Properties

* **userId** (String) — User's unique identifier
* **email** (String?) — User's email address (optional)
* **phoneNumber** (String?) — User's phone number (optional)

### Example

```swift theme={"system"}
let sdk = DynamicSDK.instance()

if let user = sdk.auth.authenticatedUser {
    print("User ID: \(user.userId)")
    print("Email: \(user.email ?? "Not provided")")
}
```

### toJsonString

Convert user profile to JSON string.

```swift theme={"system"}
if let user = sdk.auth.authenticatedUser {
    let json = user.toJsonString()
    print("User JSON: \(json)")
}
```

## BaseWallet

Represents a user's wallet.

```swift theme={"system"}
public struct BaseWallet {
    public let address: String
    public let chain: String
    public let walletName: String?
    public let id: String?
}
```

### Properties

* **address** (String) — Wallet address (0x... for EVM, base58 for Solana)
* **chain** (String) — Blockchain type ("EVM" or "SOL")
* **walletName** (String?) — Name of the wallet (e.g., "dynamicWaas")
* **id** (String?) — Wallet ID for API operations

### Example

```swift theme={"system"}
let sdk = DynamicSDK.instance()

for wallet in sdk.wallets.userWallets {
    print("Address: \(wallet.address)")
    print("Chain: \(wallet.chain)")
    print("Name: \(wallet.walletName ?? "Unknown")")
    
    if wallet.chain.uppercased() == "EVM" {
        print("This is an EVM wallet")
    } else if wallet.chain.uppercased() == "SOL" {
        print("This is a Solana wallet")
    }
}
```

## PhoneData

Phone number data for SMS authentication.

```swift theme={"system"}
public struct PhoneData {
    public let dialCode: String
    public let iso2: String
    public let phone: String
    
    public init(dialCode: String, iso2: String, phone: String)
}
```

### Properties

* **dialCode** (String) — Country dial code (e.g., "+1")
* **iso2** (String) — ISO country code (e.g., "US")
* **phone** (String) — Phone number without country code

### Example

```swift theme={"system"}
// US phone number
let usPhone = PhoneData(
    dialCode: "+1",
    iso2: "US",
    phone: "5551234567"
)

// UK phone number
let ukPhone = PhoneData(
    dialCode: "+44",
    iso2: "GB",
    phone: "7911123456"
)

try await sdk.auth.sms.sendOTP(phoneData: usPhone)
```

## GenericNetwork

Represents a blockchain network.

```swift theme={"system"}
public struct GenericNetwork {
    public let name: String
    public let chainId: ChainIdValue
    public let networkId: NetworkIdValue
    // ... other properties
}
```

### Properties

* **name** (String) — Human-readable network name
* **chainId** (ChainIdValue) — Chain ID (for EVM networks)
* **networkId** (NetworkIdValue) — Network ID (for Solana networks)

### Example

```swift theme={"system"}
let sdk = DynamicSDK.instance()

// List EVM networks
for network in sdk.networks.evm {
    print("Network: \(network.name)")
    print("Chain ID: \(network.chainId.value)")
}

// List Solana networks
for network in sdk.networks.solana {
    print("Network: \(network.name)")
}
```

## EthereumTransaction

Transaction object for sending EVM transactions.

```swift theme={"system"}
public struct EthereumTransaction {
    public let to: String
    public let value: Int
    public let gasLimit: Int
    public let maxFeePerGas: Int
    public let maxPriorityFeePerGas: Int
    public let data: String?
    
    public init(
        to: String,
        value: Int,
        gasLimit: Int,
        maxFeePerGas: Int,
        maxPriorityFeePerGas: Int,
        data: String? = nil
    )
}
```

### Properties

* **to** (String) — Recipient address
* **value** (Int) — Amount to send in Wei
* **gasLimit** (Int) — Gas limit
* **maxFeePerGas** (Int) — Maximum fee per gas unit
* **maxPriorityFeePerGas** (Int) — Priority fee per gas unit
* **data** (String?) — Transaction data (optional, for contract calls)

### Example

```swift theme={"system"}
// Simple ETH transfer
let transaction = EthereumTransaction(
    to: "0xRecipientAddress...",
    value: 1000000000000000,  // 0.001 ETH in Wei
    gasLimit: 21000,
    maxFeePerGas: 20000000000,
    maxPriorityFeePerGas: 1000000000
)

let txHash = try await sdk.evm.sendTransaction(
    transaction: transaction,
    wallet: wallet
)
```

## WriteContractInput

Input for writing to smart contracts.

```swift theme={"system"}
public struct WriteContractInput {
    public let contractAddress: String
    public let functionName: String
    public let args: [Any]
    public let abi: String
    
    public init(
        contractAddress: String,
        functionName: String,
        args: [Any],
        abi: String
    )
}
```

### Properties

* **contractAddress** (String) — Contract address
* **functionName** (String) — Name of the function to call
* **args** (\[Any]) — Arguments to pass to the function
* **abi** (String) — Contract ABI JSON string

### Example

```swift theme={"system"}
// ERC20 transfer
let input = WriteContractInput(
    contractAddress: "0xTokenContractAddress...",
    functionName: "transfer",
    args: ["0xRecipient...", "1000000"],
    abi: Erc20.abi
)

let txHash = try await sdk.evm.writeContract(wallet: wallet, input: input)
```

## SignInWithExternalJwtParams

Parameters for external JWT authentication.

```swift theme={"system"}
public struct SignInWithExternalJwtParams {
    public let jwt: String
    
    public init(jwt: String)
}
```

### Properties

* **jwt** (String) — The external JWT token

### Example

```swift theme={"system"}
let params = SignInWithExternalJwtParams(jwt: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...")

try await sdk.auth.externalAuth.signInWithExternalJwt(props: params)
```

## Erc20

ERC20 token utilities.

```swift theme={"system"}
public struct Erc20 {
    public static let abi: String
}
```

### Properties

* **abi** (String) — Standard ERC20 ABI JSON

### Example

```swift theme={"system"}
let input = WriteContractInput(
    contractAddress: tokenAddress,
    functionName: "transfer",
    args: [recipient, amount],
    abi: Erc20.abi
)
```

## GasPrice

Gas price information.

```swift theme={"system"}
public struct GasPrice {
    public let value: Int
}
```

### Example

```swift theme={"system"}
let sdk = DynamicSDK.instance()

let client = try await sdk.evm.createPublicClient(chainId: 1)
let gasPrice = try await client.getGasPrice()

print("Gas price: \(gasPrice.value) wei")
```

## DeletePasskeyRequest

Request to delete a passkey.

```swift theme={"system"}
public struct DeletePasskeyRequest {
    public let passkeyPublicKeyId: String
    
    public init(passkeyPublicKeyId: String)
}
```

### Example

```swift theme={"system"}
let request = DeletePasskeyRequest(passkeyPublicKeyId: "passkey-id-123")
try await sdk.passkeys.deletePasskey(request)
```

## EarnVaultSummary

A yield vault available to the environment, returned by `sdk.earn.getVaults`.

```swift theme={"system"}
public struct EarnVaultSummary {
    public let vaultId: String
    public let curator: String
    public let assetSymbol: String
    public let assetAddress: String
    public let chainId: Int
    public let chainName: ChainEnum
    public let netApy: Double?
    public let tvlUsd: Double?
}
```

### Properties

* **vaultId** (String) — Opaque vault identifier passed to every Earn call
* **curator** (String) — Organization curating the vault
* **assetSymbol** (String) — Ticker of the underlying asset (e.g. USDC)
* **assetAddress** (String) — Contract address of the underlying asset token
* **chainId** (Int) — Chain the vault is deployed on (Solana vaults report `101`)
* **chainName** (ChainEnum) — Chain family, `.evm` or `.sol`
* **netApy** (Double?) — Net APY as a decimal, `nil` when market data is unavailable
* **tvlUsd** (Double?) — Total value locked in USD, `nil` when unavailable

## EarnVaultDetails

Full vault details from `sdk.earn.getVaultDetails`, extending the summary fields.

```swift theme={"system"}
public struct EarnVaultDetails {
    public let vaultId: String
    public let curator: String
    public let assetSymbol: String
    public let assetAddress: String
    public let chainId: Int
    public let chainName: ChainEnum
    public let assetDecimals: Int
    public let contractAddress: String
    public let isFeeWrapper: Bool
    public let netApy: Double?
    public let tvlUsd: Double?
    public let netApyExcludingRewards: Double?
    public let tvlRaw: String?
}
```

### Properties

* **assetDecimals** (Int) — Decimals of the underlying asset, needed to convert raw amounts
* **contractAddress** (String) — Vault contract address
* Other fields match `EarnVaultSummary`

## EarnVaultPosition

A wallet's position in a vault, in raw token units.

```swift theme={"system"}
public struct EarnVaultPosition {
    public let vaultId: String
    public let ownerAddress: String
    public let shares: String
    public let assets: String
}
```

### Properties

* **shares** (String) — Internal accounting balance; not meaningful to show a user
* **assets** (String) — Current position value in the underlying token; grows as yield accrues

## EarnVaultReward

A reward a wallet accrued in a vault.

```swift theme={"system"}
public struct EarnVaultReward {
    public let accrued: String
    public let tokenAddress: String
    public let tokenDecimals: Int
    public let tokenSymbol: String
}
```

### Properties

* **accrued** (String) — Claimable amount in raw units of the reward token
* **tokenDecimals** (Int) — Decimals of the reward token; use this, not `assetDecimals`, to convert `accrued`

## EarnVaultPerformance

Morpho-indexed performance of a wallet's position in a vault.

```swift theme={"system"}
public struct EarnVaultPerformance {
    public let vaultId: String
    public let ownerAddress: String
    public let netEarningsAssets: String
    public let returnOnCapital: Double?
}
```

### Properties

* **netEarningsAssets** (String) — Net earnings in raw units of the vault asset
* **returnOnCapital** (Double?) — Time-weighted, non-annualized return as a decimal; `nil` with too little history

## EarnEarnings

Aggregate USD earnings for a wallet on one EVM chain.

```swift theme={"system"}
public struct EarnEarnings {
    public let chainId: Int
    public let ownerAddress: String
    public let totalAssetsUsd: Double
    public let totalPnlUsd: Double
    public let vaults: [EarnVaultEarnings]
}
```

### Properties

* **totalAssetsUsd** (Double) — Total position value in USD
* **totalPnlUsd** (Double) — Total profit or loss in USD, over positions whose provider reports it
* **vaults** (\[EarnVaultEarnings]) — Per-vault breakdown

## EarnVaultEarnings

Per-vault earnings entry in `EarnEarnings`.

```swift theme={"system"}
public struct EarnVaultEarnings {
    public let assets: String
    public let assetsUsd: Double?
    public let pnl: String?
    public let pnlUsd: Double?
    public let roe: Double?
    public let vaultAddress: String
    public let vaultId: String?
}
```

### Properties

* **assets** (String) — Position size in raw units of the vault asset
* **pnl**, **pnlUsd**, **roe** — Earnings figures; `nil` when the provider reports no cost basis
* **vaultId** (String?) — `nil` for vaults the environment does not offer

## EarnVaultActionResponse

Response of `deposit`, `withdraw`, and `claim`, carrying the payload for `execute`.

```swift theme={"system"}
public struct EarnVaultActionResponse {
    public let vaultId: String
    public let signingPayload: EarnSigningPayload
}
```

## EarnSigningPayload

The unsigned payload for a vault action.

```swift theme={"system"}
public struct EarnSigningPayload {
    public let chainId: String
    public let chainName: ChainEnum
    public let evmTransaction: EarnEvmTransactionData?
    public let evmApproval: EarnEvmApprovalData?
    public let transactions: [EarnTransactionStep]?
}
```

### Properties

* **chainName** (ChainEnum) — Selects the executor: `.evm` payloads carry `evmTransaction`/`evmApproval`, `.sol` payloads carry `transactions`
* **transactions** (\[EarnTransactionStep]?) — Ordered Solana transaction sequence, contiguous from `ordinal` zero

## EarnTransactionStep

One transaction in an ordered Solana vault-action sequence.

```swift theme={"system"}
public struct EarnTransactionStep {
    public let ordinal: Int
    public let payload: String
    public let label: String?
    public let expiryBlockHeight: UInt64?
}
```

### Properties

* **ordinal** (Int) — Zero-based execution order
* **payload** (String) — Base64-encoded unsigned transaction
* **expiryBlockHeight** (UInt64?) — Block height after which the transaction can no longer land

## EarnTransactionStepChange

Progress reported through `execute`'s `onTransactionStepChange` for multi-transaction actions.

```swift theme={"system"}
public struct EarnTransactionStepChange {
    public let ordinal: Int
    public let total: Int
    public let label: String?
}
```

## EarnExecutionStep

The stage a vault action reached, reported through `onStepChange`.

```swift theme={"system"}
public enum EarnExecutionStep: String {
    case approval
    case transaction
}
```

## EarnError

Thrown by Earn API calls and execution. Carries `statusCode` (the HTTP status when the failure came from the API) and `nothingToClaim` (`true` for HTTP 422 on claim).

## EarnSolanaStepError

Thrown when a Solana transaction in a sequence cannot complete, with `code` (`expired`, `failed`, `sendFailed`), `ordinal`, and `total`.

## EarnSponsorError

Thrown when `sponsored: true` was required but sponsorship was unavailable or the sponsored transaction failed.

## Error Handling

All SDK async functions can throw errors. Use Swift's native error handling:

```swift theme={"system"}
do {
    try await sdk.auth.email.verifyOTP(token: code)
} catch {
    print("Error: \(error.localizedDescription)")
    
    // Handle specific error types as needed
}
```

### Common Error Patterns

```swift theme={"system"}
do {
    let txHash = try await sdk.evm.sendTransaction(
        transaction: transaction,
        wallet: wallet
    )
} catch {
    let errorDesc = error.localizedDescription.lowercased()
    
    if errorDesc.contains("insufficient") {
        print("Insufficient funds")
    } else if errorDesc.contains("rejected") {
        print("Transaction rejected")
    } else {
        print("Transaction failed: \(error)")
    }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.