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

1. Install the SDKarrow-up-right

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 SDKarrow-up-right

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

import metamask_ios_sdk

3. Connect your dapparrow-up-right

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

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 methodsarrow-up-right

You can now call any provider API methodarrow-up-right.

The SDK uses Combinearrow-up-right to publish Ethereum events, so you need to define an AnyCancellable storage by adding the following line to your project file:

The following examples use the window.ethereum.request(args)arrow-up-right provider API method to call various RPC APIarrow-up-right methods.

Example: Get chain IDarrow-up-right

The following example gets the user's chain ID by calling eth_chainIdarrow-up-right.

Example: Get account balancearrow-up-right

The following example gets the user's account balance by calling eth_getBalancearrow-up-right.

Example: Send transactionarrow-up-right

The following examples send a transaction by calling eth_sendTransactionarrow-up-right.

  • 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.

Last updated