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.
UserProfile
Represents an authenticated user in the Dynamic 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
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.
if let user = sdk.auth.authenticatedUser {
let json = user.toJsonString()
print("User JSON: \(json)")
}
BaseWallet
Represents a user’s wallet.
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., “turnkey”)
- id (String?) - Wallet ID for API operations
Example
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.
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
// 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.
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
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.
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
// 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
)
Input for writing to smart contracts.
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
// 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.
public struct SignInWithExternalJwtParams {
public let jwt: String
public init(jwt: String)
}
Properties
- jwt (String) - The external JWT token
Example
let params = SignInWithExternalJwtParams(jwt: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...")
try await sdk.auth.externalAuth.signInWithExternalJwt(props: params)
Erc20
ERC20 token utilities.
public struct Erc20 {
public static let abi: String
}
Properties
- abi (String) - Standard ERC20 ABI JSON
Example
let input = WriteContractInput(
contractAddress: tokenAddress,
functionName: "transfer",
args: [recipient, amount],
abi: Erc20.abi
)
GasPrice
Gas price information.
public struct GasPrice {
public let value: Int
}
Example
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.
public struct DeletePasskeyRequest {
public let passkeyPublicKeyId: String
public init(passkeyPublicKeyId: String)
}
Example
let request = DeletePasskeyRequest(passkeyPublicKeyId: "passkey-id-123")
try await sdk.passkeys.deletePasskey(request)
Error Handling
All SDK async functions can throw errors. Use Swift’s native error handling:
do {
try await sdk.auth.email.verifyOTP(token: code)
} catch {
print("Error: \(error.localizedDescription)")
// Handle specific error types as needed
}
Common Error Patterns
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)")
}
}