Skip to main content

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 io.ton.walletkit.ITONWalletKit
import io.ton.walletkit.config.TONWalletKitConfiguration
import io.ton.walletkit.config.SignDataType
import io.ton.walletkit.model.TONNetwork

// 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
val bridgeURL = "https://connect.ton.org/bridge"

val features = listOf(
    // 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 = listOf(
            // Types of data to sign.
            SignDataType.TEXT, SignDataType.BINARY, SignDataType.CELL
        )
    )
)

val configuration = TONWalletKitConfiguration(
    network = TONNetwork.MAINNET, /* or TONNetwork.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
    ),
    bridge = TONWalletKitConfiguration.Bridge(
        bridgeUrl = bridgeURL
    ),
    features = features
)

Storage configuration

By default, WalletKit uses persistent storage. To set a different behavior, use the storage parameter when creating a new configuration:
val configuration = TONWalletKitConfiguration(
    // ...other fields...
    storage = TONWalletKitConfiguration.Storage(
        persistent = true // or false for memory-only storage
    )
)

Creating WalletKit instance

Once you have a configuration, create an instance of the kit:
import io.ton.walletkit.ITONWalletKit

// Instance
val walletKit = ITONWalletKit.initialize(
    context = context,
    config = configuration
)