Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.polygon.technology/llms.txt

Use this file to discover all available pages before exploring further.

The TypeScript SDK supports email OTP and OIDC authorization-code redirect authentication. After auth completes, the SDK can automatically select the first existing wallet of the requested type or create one when needed. Use manual wallet selection when your app should present wallet choices.

Start Email Auth

Send a one-time code to the user’s email address.
await oms.wallet.startEmailAuth({ email: 'user@example.com' })
Parameters
ParameterTypeDescription
emailstringEmail address that receives the one-time code.
Returns Returns Promise<void>.

Complete Email Auth

Complete the flow with the code entered by the user. Automatic mode selects the first matching wallet or creates one when none exists.
const result = await oms.wallet.completeEmailAuth({ code: '123456' })

console.log('Wallet address:', result.walletAddress)
console.log('Wallet ID:', result.wallet.id)
Use manual wallet selection when the app needs to choose between wallets before activating one.
import { WalletType } from '@0xsequence/typescript-sdk'

const selection = await oms.wallet.completeEmailAuth({
  code: '123456',
  walletType: WalletType.Ethereum,
  walletSelection: 'manual',
})

await selection.createAndSelectWallet({ reference: 'main' })
Parameters
ParameterTypeDescription
codestringOne-time code entered by the user.
walletTypeWalletType or undefinedOptional wallet type. Defaults to WalletType.Ethereum.
walletSelection'automatic' or 'manual'Defaults to 'automatic'. Use 'manual' to receive a pending wallet selection.
Returns Returns Promise<CompleteEmailAuthResult> in automatic mode, or Promise<PendingWalletSelection> in manual mode.
FieldTypeDescription
walletAddressAddressActive embedded wallet address.
walletOmsWalletSelected or created wallet.
walletsOmsWallet[]Wallets returned by auth completion.
credentialWalletCredentialCredential added by auth completion.

Start OIDC Redirect Auth

Start an OIDC authorization-code PKCE flow. The default environment includes a google provider.
const redirect = await oms.wallet.startOidcRedirectAuth({
  provider: 'google',
  redirectUri: `${window.location.origin}/auth/callback`,
})

window.location.assign(redirect.url)
Parameters
ParameterTypeDescription
providerProvider name or provider configConfigured provider name, such as google, or an inline provider config.
redirectUristringApp callback URL that receives the provider redirect.
walletTypeWalletType or undefinedOptional wallet type. Defaults to WalletType.Ethereum.
relayRedirectUristring or undefinedOptional relay callback URL when the provider must redirect through a relay.
authorizeParamsRecord<string, string> or undefinedExtra authorization query parameters passed to the provider.
Returns Returns Promise<StartOidcRedirectAuthResult>.
FieldTypeDescription
urlstringProvider authorization URL.
statestringEncoded OIDC state value stored for callback validation.
challengestringWallet auth challenge used in the OIDC request.

Complete OIDC Redirect Auth

Complete the redirect flow after the provider sends the user back to your app.
const result = await oms.wallet.completeOidcRedirectAuth({
  callbackUrl: window.location.href,
  cleanUrl: true,
})

console.log('Wallet address:', result.walletAddress)
Parameters
ParameterTypeDescription
callbackUrlstringFull callback URL containing the OIDC code and state query parameters.
cleanUrlboolean or undefinedWhether to remove OIDC query parameters from the current URL after parsing.
replaceUrlURL replacement callback or undefinedCustom URL replacement callback for non-browser runtimes or routers.
walletSelection'automatic' or 'manual'Defaults to 'automatic'. Use 'manual' to receive a pending wallet selection.
Returns Returns Promise<CompleteOidcRedirectAuthResult> in automatic mode, or Promise<PendingWalletSelection> in manual mode.

Sign In With OIDC Redirect

Use this browser convenience wrapper when one call should start auth on normal pages and complete auth on callback pages.
const result = await oms.wallet.signInWithOidcRedirect({
  provider: 'google',
})

if (result && 'walletAddress' in result) {
  console.log('Wallet address:', result.walletAddress)
}
Parameters
ParameterTypeDescription
providerProvider name or provider configConfigured provider name or inline provider config.
redirectUristring or undefinedApp callback URL. Defaults to the current browser URL without OIDC callback params.
walletTypeWalletType or undefinedOptional wallet type. Defaults to WalletType.Ethereum.
walletSelection'automatic' or 'manual'Defaults to 'automatic'.
relayRedirectUristring or undefinedOptional relay callback URL.
authorizeParamsRecord<string, string> or undefinedExtra authorization query parameters passed to the provider.
cleanUrlboolean or undefinedWhether callback completion should clean the URL. Defaults to true.
currentUrlstring or undefinedExplicit current URL for non-browser routing flows.
assignUrlURL assignment callback or undefinedCustom redirect function. Defaults to window.location.assign.
replaceUrlURL replacement callback or undefinedCustom callback URL cleanup function.
Returns Returns Promise<CompleteOidcRedirectAuthResult | PendingWalletSelection | void>.

Use Wallet

Activate an existing wallet by server-side wallet ID.
await oms.wallet.useWallet({ walletId: 'wallet-id' })
Parameters
ParameterTypeDescription
walletIdstringWallet ID returned by auth completion or listWallets.
Returns Returns Promise<WalletActivationResult>.

Create Wallet

Create and activate a new wallet for the authenticated user.
const result = await oms.wallet.createWallet({
  reference: 'main',
})

console.log('New wallet:', result.walletAddress)
Parameters
ParameterTypeDescription
typeWalletType or undefinedWallet type to create. Defaults to WalletType.Ethereum.
referencestring or undefinedOptional app-defined wallet reference.
Returns Returns Promise<WalletActivationResult>.