Documentation Index
Fetch the complete documentation index at: https://companyname-a7d5b98e-closes-1950-ai-ai-ai-ai-ai-ai-ai.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Creating configuration
The basic kit initialization consists of creating a corresponding object by passing it a minimal set of necessary arguments. Pick a TON network to operate on, a wallet manifest, and feature configurations.
Here is an example of a minimal configuration:
import TONWalletKit
// URL of the wallet's implementation of the HTTP bridge:
// https://github.com/ton-connect/docs/blob/main/bridge.md#http-bridge
//
// Can be different, e.g., https://bridge.tonapi.io/bridge
let bridgeURL = "https://connect.ton.org/bridge"
let features: [TONWalletKitConfiguration.Feature] = [
// Wallet can send transactions.
TONWalletKitConfiguration.SendTransactionFeature(
// Max number of messages that can be sent in a single transaction.
// Depends on the TON wallet used, because different kinds can handle
// different number of messages.
maxMessages: 1,
// Are messages sending extra-currencies supported?
extraCurrencySupported: false
),
TONWalletKitConfiguration.SignDataFeature(types: [
// Types of data to sign.
.text, .binary, .cell
]),
]
let configuration = TONWalletKitConfiguration(
network: .mainnet, /* or .testnet */
walletManifest: TONWalletKitConfiguration.Manifest(
name: "Name of your wallet service",
appName: "your_wallet_service_id", /* e.g. best_ton_wallet_service */
imageUrl: "https://<YOUR_WALLET_SERVICE_URL>/image.png",
aboutUrl: "https://<YOUR_WALLET_SERVICE_URL>/about",
universalLink: "https://<YOUR_WALLET_SERVICE_URL>/universal-link",
bridgeUrl: bridgeURL
),
features: features
)
Creating WalletKit instance
Once you have a configuration, create an instance of the kit:
import TONWalletKit
// Instructs how to store intermediate events and other data from the WalletKit.
let storage: TONWalletKitStorageType = .memory // .keychain or .custom(/* custom storage */)
// Instance
let walletKit = try await TONWalletKit.initialize(
configuration: configuration,
storage: storage
)
Creating custom storage
One can implement a custom storage and provide it during initialization:
import TONWalletKit
class YourCustomStorage: TONWalletKitStorage {
func save(key: String, value: String) throws { ... }
func get(key: String) throws -> String? { ... }
func remove(key: String) throws { ... }
func clear() throws { ... }
}
let walletKit = try await TONWalletKit.initialize(
configuration: configuration,
storage: .custom(YourCustomStorage())
)