Skip to main content

Actions

Chains

Chain selection

You can select your own chain by calling the selectChain(_ chain: Chain) static method on the Web3Modal object.

Get selected chain

You can get selected chain by calling the getSelectedChain() static method on the Web3Modal object.

Sign Actions

Create pairing

let uri: WalletConnectURI = try await Web3Modal.instance.createPairing()

Connect

try await Web3Modal.instance.connect(
requiredNamespaces: [String: ProposalNamespace],
optionalNamespaces: [String: ProposalNamespace]?,
sessionProperties: [String: String]?,
topic: topic // Can be existing topic or nil to create new one
)

// Or without specifying namespaces to stick with default values

try await Web3Modal.instance.connect(
topic: topic // Can be existing topic or nil to create new one
)

More about optional and required namespaces can be found here

Disconnect

try await Web3Modal.instance.disconnect(topic: topic)

Request

try await Web3Modal.instance.request(
params: .init(
topic: session.topic,
method: "some_method",
params: AnyCodable(payload),
chainId: Blockchain
)
)

Get List of Active Sessions

Web3Modal.instance.getSessions()

To get a list of active sessions, call Web3Modal.instance.getSessions() which will return [Session].

launch connected wallet

Web3Modal.instance.launchCurrentWallet()

To open a wallet that your dapp is connected to

Web3Modal.instance.handleDeeplink(url)

Cleanup

Web3Modal.instance.cleanup(topic)

Delete all stored data such as: pairings, sessions, keys