Network
Network layer documentation for Flow Wallet Kit iOS SDK
Network
The Flow Wallet Kit for iOS provides a robust networking layer for interacting with the Flow blockchain and related services.
Network Layer
The Flow Wallet Kit network layer handles communication with the Flow blockchain and key indexer services. This documentation covers the network operations and data structures used for blockchain interactions.
Key Indexer Service
The key indexer service helps locate Flow accounts associated with specific public keys. This is essential for account recovery and key management.
KeyIndexerResponse
The main response structure from the Flow key indexer service:
Account Structure
Each account in the response contains:
Field | Type | Description |
---|---|---|
address | String | Flow address in hex format |
keyId | Int | Key index in the account |
weight | Int | Key weight (determines signing authority) |
sigAlgo | Int | Signature algorithm identifier |
hashAlgo | Int | Hash algorithm identifier |
signing | Flow.SignatureAlgorithm | Signature algorithm used |
hashing | Flow.HashAlgorithm | Hash algorithm used |
isRevoked | Bool | Whether the key has been revoked |
Network Operations
Finding Accounts
There are three main methods for finding accounts:
1. Find Raw Account Information
Returns the raw KeyIndexerResponse
containing all account information.
2. Find Account Details
Returns an array of KeyIndexerResponse.Account
objects.
3. Find Flow Accounts
Returns an array of Flow.Account
objects, which are the native Flow account representations.
Error Handling
The network layer can throw several specific errors:
FWKError.incorrectKeyIndexerURL
: Invalid key indexer service URLFWKError.keyIndexerRequestFailed
: Failed to communicate with key indexerFWKError.decodeKeyIndexerFailed
: Failed to decode the response
Example error handling:
Response Transformations
The network layer automatically transforms key indexer responses into Flow account objects. This transformation:
- Aggregates keys by account address
- Converts hex addresses to Flow.Address types
- Creates proper Flow.AccountKey objects
- Maintains all key properties (weight, algorithms, revocation status)
Best Practices
-
Chain ID Selection: Always use the appropriate chain ID for your environment:
.mainnet
for production.testnet
for testing.emulator
for local development
-
Error Handling: Implement proper error handling for network operations
-
Response Processing: Consider caching responses for frequently accessed accounts
-
Key Management: Verify key status (revoked, weight) before using accounts
Example Usage
Here's a complete example of finding and processing Flow accounts: