If you chose to prompt the user on sign in during the configuration step, the user is prompted to approve delegation for your application when they next sign in.
You can use the initDelegationProcess method from the wallets module to open the delegation modal UI:
// Open the delegation modal for all eligible walletsDynamicSDK.instance.wallets.initDelegationProcess()// Or specify which wallets to delegateDynamicSDK.instance.wallets.initDelegationProcess( walletIds = listOf("wallet-id-1", "wallet-id-2"))
You can observe delegation state changes using Kotlin’s StateFlow:
import kotlinx.coroutines.flow.collect// Get current state synchronouslyval state = DynamicSDK.instance.wallets.delegatedAccessStateprintln("Enabled: ${state.delegatedAccessEnabled}")println("Required: ${state.requiresDelegation}")// Listen to state changes (in a coroutine scope)DynamicSDK.instance.wallets.delegatedAccessChanges.collect { state -> state.walletsDelegatedStatus.forEach { wallet -> println("${wallet.address}: ${wallet.status}") }}
// Get status of all walletsval statuses = DynamicSDK.instance.wallets.getWalletsDelegatedStatus()statuses.forEach { status -> println("Wallet ${status.address} on ${status.chain}: ${status.status}")}// Get status for a specific walletval status = DynamicSDK.instance.wallets.getDelegationStatusForWallet("wallet-id")status?.let { println("Status: ${it.status}") // DELEGATED, PENDING, or DENIED}
// Dismiss the prompt for the current session only (resets on logout/restart)DynamicSDK.instance.wallets.dismissDelegationPrompt()// Or dismiss for a specific walletDynamicSDK.instance.wallets.dismissDelegationPrompt(walletId = "wallet-id")// Permanently deny delegation for a wallet (user won't be prompted again)DynamicSDK.instance.wallets.denyWalletDelegation(walletId = "wallet-id")// Clear all session dismissalsDynamicSDK.instance.wallets.clearDelegationSessionState()
What's next?
Learn how to properly receive the delegation materials on your server