> For the complete documentation index, see [llms.txt](https://pools-chain.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pools-chain.gitbook.io/documentation/built-for-developers/pools-sdk/supported-platforms/mobile/native-ios.md).

# Native IOS

You can import Pools SDK into your native iOS dapp to enable your users to easily connect with Pools Chain and Pools Wallet

### Steps[​](https://docs.metamask.io/wallet/how-to/connect/set-up-sdk/mobile/ios/#steps) <a href="#steps" id="steps"></a>

#### 1. Install the SDK[​](https://docs.metamask.io/wallet/how-to/connect/set-up-sdk/mobile/ios/#1-install-the-sdk) <a href="#id-1-install-the-sdk" id="id-1-install-the-sdk"></a>

To add the SDK as a Swift Package Manager (SPM) package to your project, in Xcode, select **File > Swift Packages > Add Package Dependency**.

Alternatively, you can add the URL directly in your project's package file:

```
dependencies: [
    .package(
        url: "https://github.com/MetaMask/metamask-ios-sdk",
        from: "0.1.0"
    )
]
```

NOTE

The SDK supports `ios-arm64` (iOS devices) and `ios-arm64-simulator` (M1 chip simulators). It currently doesn't support `ios-ax86_64-simulator` (Intel chip simulators).

#### 2. Import the SDK[​](https://docs.metamask.io/wallet/how-to/connect/set-up-sdk/mobile/ios/#2-import-the-sdk) <a href="#id-2-import-the-sdk" id="id-2-import-the-sdk"></a>

Import the SDK by adding the following line to the top of your project file:

```
import metamask_ios_sdk
```

#### 3. Connect your dapp[​](https://docs.metamask.io/wallet/how-to/connect/set-up-sdk/mobile/ios/#3-connect-your-dapp) <a href="#id-3-connect-your-dapp" id="id-3-connect-your-dapp"></a>

Connect your dapp by adding the following code to your project file:

```
@ObservedObject var ethereum = MetaMaskSDK.shared.ethereum

let dapp = Dapp(name: "Dub Dapp", url: "https://dubdapp.com")

// This is the same as calling eth_requestAccounts
ethereum.connect(dapp)
```

By default, MetaMask logs three SDK events: `connectionRequest`, `connected`, and `disconnected`. This allows MetaMask to monitor any SDK connection issues. To disable this, set `MetaMaskSDK.shared.enableDebug = false` or `ethereum.enableDebug = false`.

#### 4. Call provider methods[​](https://docs.metamask.io/wallet/how-to/connect/set-up-sdk/mobile/ios/#4-call-provider-methods) <a href="#id-4-call-provider-methods" id="id-4-call-provider-methods"></a>

You can now call any [provider API method](https://docs.metamask.io/wallet/reference/provider-api/).

The SDK uses [Combine](https://developer.apple.com/documentation/combine) to publish Ethereum events, so you need to define an `AnyCancellable` storage by adding the following line to your project file:

```
@State private var cancellables: Set<AnyCancellable> = []
```

The following examples use the [`window.ethereum.request(args)`](https://docs.metamask.io/wallet/reference/provider-api/#windowethereumrequestargs) provider API method to call various [RPC API](https://docs.metamask.io/wallet/reference/rpc-api/) methods.

**Example: Get chain ID**[**​**](https://docs.metamask.io/wallet/how-to/connect/set-up-sdk/mobile/ios/#example-get-chain-id)

The following example gets the user's chain ID by calling [`eth_chainId`](https://docs.metamask.io/wallet/reference/eth_chainId/).

```
@State var chainId: String?

let chainIdRequest = EthereumRequest(method: .ethChainId)

ethereum.request(chainIdRequest)?.sink(receiveCompletion: { completion in
    switch completion {
    case .failure(let error):
        print("\(error.localizedDescription)")
    default: break
    }
}, receiveValue: { result in
    self.chainId = result
})
.store(in: &cancellables)
```

**Example: Get account balance**[**​**](https://docs.metamask.io/wallet/how-to/connect/set-up-sdk/mobile/ios/#example-get-account-balance)

The following example gets the user's account balance by calling [`eth_getBalance`](https://docs.metamask.io/wallet/reference/eth_getBalance/).

```
@State var balance: String?

// Create parameters
let parameters: [String] = [
    ethereum.selectedAddress, // address to check for balance
    "latest" // "latest", "earliest" or "pending" (optional)
  ]

// Create request
let getBalanceRequest = EthereumRequest(
    method: .ethGetBalance,
    params: parameters)

// Make request
ethereum.request(getBalanceRequest)?.sink(receiveCompletion: { completion in
    switch completion {
    case .failure(let error):
        print("\(error.localizedDescription)")
    default: break
    }
}, receiveValue: { result in
    self.balance = result
})
.store(in: &cancellables)
```

**Example: Send transaction**[**​**](https://docs.metamask.io/wallet/how-to/connect/set-up-sdk/mobile/ios/#example-send-transaction)

The following examples send a transaction by calling [`eth_sendTransaction`](https://docs.metamask.io/wallet/reference/eth_sendTransaction/).

* Use a dictionary
* Use a struct

If your request parameters make up a simple dictionary of string key-value pairs, you can use the dictionary directly. Note that `Any` or even `AnyHashable` types aren't supported, since the type must be explicitly known.

```
// Create parameters
let parameters: [String: String] = [
    "to": "0x...", // receiver address
    "from": ethereum.selectedAddress, // sender address
    "value": "0x..." // amount
  ]

// Create request
let transactionRequest = EthereumRequest(
    method: .ethSendTransaction,
    params: [parameters] // eth_sendTransaction expects an array parameters object
    )

// Make a transaction request
ethereum.request(transactionRequest)?.sink(receiveCompletion: { completion in
    switch completion {
    case .failure(let error):
        print("\(error.localizedDescription)")
    default: break
    }
}, receiveValue: { result in
    print(result)
})
.store(in: &cancellables)
```
