authenticate
Authenticates a crypto wallet by signing a server-issued challenge with the wallet's private key. Performs a two-step flow: calls POST /sdk/v1/crypto_wallets/authenticate/start/primary (no session) or POST /sdk/v1/crypto_wallets/authenticate/start/secondary (with session) to get a challenge string, invokes signChallenge to sign it, then calls POST /sdk/v1/crypto_wallets/authenticate to complete authentication.
Kotlin:
StytchConsumer.crypto.authenticate(
request = CryptoWalletsAuthenticateParameters(
cryptoWalletAddress = "0xABC123...",
cryptoWalletType = "ethereum",
sessionDurationMinutes = 30,
),
signChallenge = { challenge -> myWallet.signMessage(challenge) },
)iOS:
let params = CryptoWalletsAuthenticateParameters(
cryptoWalletAddress: "0xABC123...",
cryptoWalletType: "ethereum",
sessionDurationMinutes: 30
)
let response = try await StytchConsumer.crypto.authenticate(params) { challenge in
return myWallet.signMessage(challenge)
}React Native:
StytchConsumer.crypto.authenticate(
{ cryptoWalletAddress: "0xABC123...", cryptoWalletType: "ethereum", sessionDurationMinutes: 30 },
(challenge) => myWallet.signMessage(challenge),
)Return
CryptoWalletsAuthenticateResponse containing the authenticated session and user.
Parameters
ICryptoWalletsAuthenticateParameters
cryptoWalletAddress— The public wallet address (e.g. an Ethereum address).cryptoWalletType— The wallet type identifier (e.g."ethereum","solana").sessionDurationMinutes— Duration of the session to create, in minutes.
A suspend function that receives the server-issued challenge string and returns the hex-encoded signature produced by the wallet's private key.
Throws
if the wallet address is not registered or the signature is invalid.
if the coroutine is cancelled.