API Reference

Android SDK API Reference

Public CROSSxSDK API reference.


Configuration

SDKConfig

SDK initialization configuration object.

// Convenience constructor — appId and appVersion are derived from context
SDKConfig(
    context = application,
    projectId = "...",
    appName = "...",
    callbackScheme = SDKConfig.defaultScheme(projectId),
    theme = SDKThemeMode.Light,
    themeTokens = SDKThemeTokens(),
    logger = null
)

// Primary constructor — provide appId explicitly
SDKConfig(
    projectId = "...",
    appId = "com.example.myapp",   // Gradle applicationId (including flavor suffix)
    appName = "...",
    appVersion = "1.0.0",          // sent as X-App-Version header
    callbackScheme = SDKConfig.defaultScheme(projectId)
)
ParameterTypeDescription
projectIdStringCROSSx project identifier
appIdStringGradle applicationId including any flavor suffix. Omit to derive from context
appNameStringHost app display name shown in SDK UI
appVersionStringApp version string sent as X-App-Version header (e.g. "1.0.0"). Defaults to "". Auto-populated from PackageManager when using the convenience constructor
callbackSchemeStringOAuth deep-link scheme. Use SDKConfig.defaultScheme(projectId)
themeSDKThemeModeInitial theme mode (default: Light)
themeTokensSDKThemeTokensColor token overrides per theme
loggerLoggerPort?Optional logger for SDK debug output

SDKSignInProvider

Selects the OAuth provider shown during signIn() / signInWithCreate().

enum class SDKSignInProvider {
    All,
    Google,
    Apple
}

All shows the provider selection sheet; Google / Apple skip directly to that provider.


Theme

SDKThemeMode / SDKThemeTokens

enum class SDKThemeMode { Light, Dark, System }

data class SDKThemeTokens(
    val light: SDKColorOverrides = SDKColorOverrides(),
    val dark: SDKColorOverrides = SDKColorOverrides()
)

Pass to SDKConfig or applyTheme() to control the visual appearance of SDK modals.

SDKColorOverrides

Per-mode color overrides. All fields are optional; unset fields fall back to SDK defaults. Colors use 0xAARRGGBB.

data class SDKColorOverrides(
    val primary: Long? = null,
    val secondary: Long? = null,
    val onPrimary: Long? = null,
    val borderDefault: Long? = null,
    val borderSubtle: Long? = null,
    val textIconPrimary: Long? = null,
    val textIconSecondary: Long? = null,
    val textIconTertiary: Long? = null,
    val surfaceDefault: Long? = null,
    val surfaceSubtle: Long? = null,
    val bg: Long? = null
)

Core

config

val config: SDKConfig

Read-only configuration provided at construction.


handleUrl()

fun handleUrl(url: String): Boolean

Routes an incoming deep-link URL to the SDK's OAuth callback handler. Call this from your Activity.onNewIntent() or Activity.onCreate() when the URL matches your callbackScheme.

Returns true if the URL was handled by the SDK, false otherwise.


initialize()

suspend fun initialize(): AuthResult?

Attempts to restore a previously stored session. Also calls applyTheme() with the current config values.

  • If a valid session is found and backend wallet validation succeeds, returns an AuthResult.
  • If backend validation fails, the local session may be cleared and null is returned.
  • Call this on app start before checking isLoggedIn().

Returns AuthResult? — restored session info, or null if no session could be restored.


applyTheme()

fun applyTheme(
    themeMode: SDKThemeMode = config.theme,
    themeTokens: SDKThemeTokens = config.themeTokens
)

Applies theme configuration to SDK modals. If not called, SDK UI uses its built-in default palette. initialize() calls this automatically with the config values; call manually only when changing the theme at runtime.

ParameterDefaultDescription
themeModeconfig.themeLight / Dark / System
themeTokensconfig.themeTokensColor token overrides

signIn()

suspend fun signIn(provider: SDKSignInProvider = SDKSignInProvider.All): AuthResult

Launches the OAuth sign-in flow. Shows the provider selection sheet (or skips directly to the given provider) and suspends until the user completes or cancels. Does not create or migrate a wallet.

ParameterDefaultDescription
providerAllOAuth provider to use

Returns AuthResult — auth state and user info.


signInAgain()

suspend fun signInAgain(): AuthResult

Re-runs the sign-in flow for an already-authenticated user without showing the full OAuth provider selection. Use this to re-validate an expired session without forcing the user to choose a provider again.

Returns AuthResult after re-authentication.


signInWithJWT()

suspend fun signInWithJWT(
    idToken: String,
    providerSub: String? = null,
    provider: String? = null
): AuthResult

Signs in using a Firebase ID Token obtained externally (e.g. from React Native or a custom auth flow). The SDK exchanges the token with the backend /cross-auth/social/login and creates a session identical to a standard signIn(). All getUserInfo() fields are populated normally after this call.

ParameterDefaultDescription
idTokenFirebase ID Token
providerSubnullOAuth provider's unique user ID (extracted from idToken if not provided)
providernullOAuth provider identifier (e.g. "google", "apple"; extracted from idToken if not provided)

Returns AuthResult.

Throws CROSSxError.AuthFailed if the backend token exchange or validation fails.


signInWithCreate()

suspend fun signInWithCreate(provider: SDKSignInProvider = SDKSignInProvider.All): AuthResult

Same OAuth flow as signIn(), then automatically continues with wallet creation or migration after authentication completes. If wallet creation fails, the session is signed out and the error is thrown.

ParameterDefaultDescription
providerAllOAuth provider to use

Returns AuthResult with the resolved wallet address.


signOut()

suspend fun signOut()

Clears the local session, access/refresh tokens, and OAuth state. Subsequent calls to isLoggedIn() will return false.


refreshToken()

suspend fun refreshToken(): String

Forces a token refresh using the stored refresh token.

Returns the new access token as a String.

Throws CROSSxError.NotAuthenticated if no refresh token is stored.


isLoggedIn()

fun isLoggedIn(): Boolean

Returns true if a stored access token exists and has not expired. This is a local check — no network call is made. For a full session restore with server validation, call initialize().


ensureLoggedIn()

suspend fun ensureLoggedIn(): Boolean

Ensures the current session is usable:

  • If the local access token is still valid, returns true immediately.
  • Otherwise attempts session restore and refresh via initialize().
  • Returns false when no restorable session exists.

Returns Booleantrue if a valid session is available, false if the user must sign in.


getUserInfo()

suspend fun getUserInfo(): SDKUserInfo

Builds SDKUserInfo from the JWT payload, persisted OAuth tokens, and the user's wallet address list. The addresses list may be empty if the wallet password is not set yet and address lookup is blocked by CROSSxError.WalletPasswordRequired.

Returns SDKUserInfo with provider info, tokens, email, sub, and wallet addresses.


Wallet Password and Biometrics

Wallet passwords are stored securely after confirmation UI and reused for later signing and sending operations.

canUseBiometric()

fun canUseBiometric(): Boolean

Returns true if biometric hardware (fingerprint, face) is available and enrolled on the device.


isBiometricEnabled()

fun isBiometricEnabled(): Boolean

Returns true if biometric unlock is currently enabled for the current user's wallet.


setBiometricEnabled()

suspend fun setBiometricEnabled(enabled: Boolean)

Enables or disables biometric unlock for wallet operations. When enabling, the user is prompted for their existing wallet password to register the biometric credential.

ParameterDescription
enabledtrue to enable biometric unlock, false to disable

Addresses / Wallet

getAddress()

suspend fun getAddress(index: Int? = null): GetAddressResp

Returns the wallet address at the given index. Pass null (default) to get the first/default address.

ParameterDefaultDescription
indexnullAddress index; null = first address

getAddresses()

suspend fun getAddresses(): GetAddressesResp

Returns all wallet addresses associated with the current user.


setAddressNames()

suspend fun setAddressNames(names: List<AddressNameEntry>): Unit

Bulk sets or deletes address labels.

  • names must contain at most 10 entries.
  • Each non-empty name must be 4–24 characters and must not contain: `< > " ' ; \ $ & | ``
  • An empty string for AddressNameEntry.name deletes the label for that address.
  • Addresses not found in the server's DB are silently ignored.

Throws CROSSxError.InvalidAddressName if any name fails validation.


selectWallet()

suspend fun selectWallet(activity: Activity, currentAddress: String? = null): SelectedWallet

Presents a wallet selection UI to the user.

ParameterDefaultDescription
activityHost Activity for the modal
currentAddressnullAddress to pre-select; null for no pre-selection

Returns SelectedWallet with the chosen address and index.


checkWallet()

suspend fun checkWallet(): WalletCheckResp

Queries the server for the current wallet state without creating or modifying any wallet. Useful to branch logic before calling createWallet().

Returns WalletCheckRespresult is one of exists | migration_required | not_found.


createWallet()

suspend fun createWallet(migrateAutomatically: Boolean = true): CreateWalletResp

Creates a new wallet or migrates an existing one, with UI for password/PIN entry.

ParameterDefaultDescription
migrateAutomaticallytrueWhen migration_required: true migrates automatically, false throws CROSSxError.MigrationRequired

Branches:

  • exists — returns the existing wallet address.
  • migration_required + migrateAutomatically = true — migrates and returns the new address.
  • migration_required + migrateAutomatically = false — throws CROSSxError.MigrationRequired.
  • not_found — creates a new wallet and returns the address.

Returns CreateWalletResp with the resolved address.

The public crossx-sdk-core artifact does not expose mnemonic export, private key export, password change, or account deletion APIs.


Signing / Sending

All signing and sending methods require activity and chainId. Prefer CAIP-2 format eip155:<number> for chainId (e.g. eip155:1, eip155:612044).

If dappName is blank, SDKConfig.appName is used. from must not be empty for sign and send flows.

signMessage()

suspend fun signMessage(
    activity: Activity,
    message: String,
    chainId: String,
    from: String? = null,
    dappName: String = "",
    accountName: String = "Account"
): SignMessageResp

Shows a confirmation dialog and signs a plain-text message with the user's wallet.

ParameterDefaultDescription
activityHost Activity for the confirmation UI
messagePlain text message to sign
chainIdCAIP-2 chain identifier (e.g. eip155:1)
fromnullSigning address; must not be empty for production use
dappName""DApp display name shown in the UI (falls back to SDKConfig.appName)
accountName"Account"Account label shown in the UI

signTypedData() — JSON string

suspend fun signTypedData(
    activity: Activity,
    typedDataJson: String,
    chainId: String,
    from: String? = null,
    dappName: String = "",
    accountName: String = "Account"
): SignTypedDataResp

Shows a confirmation dialog and signs EIP-712 typed data supplied as a JSON string. May perform extra RPC calls (e.g. eth_call) for token metadata.

For on-chain typed data, align chainId to eip155:<n> and match domain.chainId in the payload to the same numeric chain ID.


signTypedData() — Eip712TypedData object

suspend fun signTypedData(
    activity: Activity,
    typedData: Eip712TypedData,
    chainId: String,
    from: String? = null,
    dappName: String = "",
    accountName: String = "Account"
): SignTypedDataResp

Same as above, but accepts a pre-parsed Eip712TypedData object instead of a JSON string.


signTypedDataOffchain()

// JSON string overload
suspend fun signTypedDataOffchain(
    activity: Activity,
    typedDataJson: String,
    from: String? = null,
    dappName: String = "",
    accountName: String = "Account"
): SignTypedDataResp

// Eip712TypedData object overload
suspend fun signTypedDataOffchain(
    activity: Activity,
    typedData: Eip712TypedData,
    from: String? = null,
    dappName: String = "",
    accountName: String = "Account"
): SignTypedDataResp

Signs EIP-712 typed data for off-chain use cases where domain.chainId is absent. Internally uses chainId = "0".

Use this instead of signTypedData() when the payload omits domain.chainId. Sending an on-chain payload here will cause the server to return -10026 (domain chainId mismatch).


signTransaction()

// UnsignedTx overload
suspend fun signTransaction(
    activity: Activity,
    unsignedTx: UnsignedTx,
    chainId: String,
    dappName: String = "",
    networkName: String? = null,
    estimatedFee: String? = null,
    amount: String? = null
): SignTxResp

// WalletUnsignedTransaction overload
suspend fun signTransaction(
    activity: Activity,
    unsignedTx: WalletUnsignedTransaction,
    chainId: String,
    dappName: String = "",
    networkName: String? = null,
    estimatedFee: String? = null,
    amount: String? = null
): SignTxResp

Shows a confirmation dialog and signs a transaction. The signed transaction is not broadcast to the network — use sendTransaction() to sign and broadcast in one step.

ParameterDefaultDescription
networkNamenullHuman-readable network name shown in the confirmation UI
estimatedFeenullFee string shown in the confirmation UI
amountnullAmount string shown in the confirmation UI

sendTransaction()

// UnsignedTx overload
suspend fun sendTransaction(
    activity: Activity,
    unsignedTx: UnsignedTx,
    chainId: String,
    dappName: String = "",
    networkName: String? = null,
    estimatedFee: String? = null,
    amount: String? = null
): SendTxResp

// WalletUnsignedTransaction overload
suspend fun sendTransaction(
    activity: Activity,
    unsignedTx: WalletUnsignedTransaction,
    chainId: String,
    dappName: String = "",
    networkName: String? = null,
    estimatedFee: String? = null,
    amount: String? = null
): SendTxResp

Shows a confirmation dialog, signs, and broadcasts the transaction to the network.


sendTransactionWithWaitForReceipt()

suspend fun sendTransactionWithWaitForReceipt(
    activity: Activity,
    unsignedTx: UnsignedTx,           // or WalletUnsignedTransaction
    chainId: String,
    dappName: String = "",
    networkName: String? = null,
    estimatedFee: String? = null,
    amount: String? = null,
    timeoutMs: Long = 30_000,
    pollIntervalMs: Long = 1_000
): TransactionReceipt

Same as sendTransaction() but also polls for the on-chain transaction receipt before returning. Available for both UnsignedTx and WalletUnsignedTransaction.

ParameterDefaultDescription
timeoutMs30_000Maximum time to wait for receipt (ms)
pollIntervalMs1_000Polling interval (ms)

Throws CROSSxError.Timeout if the receipt is not confirmed within timeoutMs.


RPC / Helpers

walletRpc()

suspend fun walletRpc(request: JsonRpcRequest, chainId: String): String

Generic JSON-RPC request routed through the gateway chain resolver. Resolves the chain RPC URL via the gateway, caches it in memory, and sends the request directly to the node.

Use this for reads and calls (e.g. eth_call). For signing and broadcasting, use the dedicated APIs.

JsonRpcRequest.params must be a JSON array string (e.g. [], ["0xabc","latest"]).

Returns the raw JSON-RPC response as a String.


getBalance()

suspend fun getBalance(
    address: String,
    chainId: String,
    blockTag: String = "latest"
): String

Calls eth_getBalance(address, blockTag) against the resolved chain RPC URL.

ParameterDefaultDescription
addressEVM wallet address
chainIdCAIP-2 chain identifier
blockTag"latest"Block tag ("latest", "pending", etc.)

Returns hex string balance in wei, e.g. "0x0".


getNonce()

suspend fun getNonce(
    address: String,
    chainId: String,
    blockTag: String = "pending"
): String

Calls eth_getTransactionCount(address, blockTag) against the resolved chain RPC URL. Use "pending" (default) to include pending transactions — recommended before signing or sending.

ParameterDefaultDescription
addressEVM wallet address
chainIdCAIP-2 chain identifier
blockTag"pending"Block tag ("pending" recommended for pre-sign nonce)

Returns hex string nonce, e.g. "0x0".


waitForTxAndGetReceipt()

suspend fun waitForTxAndGetReceipt(
    txHash: String,
    chainId: String,
    timeoutMs: Long = 30_000,
    pollIntervalMs: Long = 1_000
): TransactionReceipt

Polls the chain for a transaction receipt until the transaction is confirmed or the timeout is reached. Use this when you already have a txHash from a prior sendTransaction() call and want to wait for confirmation separately.

ParameterDefaultDescription
txHashTransaction hash to wait for
chainIdCAIP-2 chain identifier
timeoutMs30_000Maximum wait time (ms)
pollIntervalMs1_000Polling interval (ms)

Throws CROSSxError.Timeout if not confirmed within timeoutMs.


Legacy Entry Points

These remain for backward compatibility with older integrations. Prefer the wallet-centric APIs above in new code.

signMessage() (legacy)

suspend fun signMessage(message: String, networkId: NetworkId): SignatureResult

sendTransaction() (legacy)

suspend fun sendTransaction(params: TransactionParams): TransactionResult

Types

UnsignedTx

FieldDescription
chainIdCAIP-2 chain identifier
fromSender address
toRecipient address
valueETH value (hex string)
dataCall data (hex string)
nonceTransaction nonce (hex string)
gasLimitGas limit (hex string)
gasPriceGas price for legacy transactions (hex string)
maxFeePerGasEIP-1559 max fee (hex string)
maxPriorityFeePerGasEIP-1559 priority fee (hex string)

WalletUnsignedTransaction.EvmEip155

FieldDescription
chainIdCAIP-2 chain identifier
fromSender address
toRecipient address
valueETH value (hex string)
dataCall data (hex string)
nonceTransaction nonce
gasLimitGas limit
gasPriceGas price for legacy transactions
maxFeePerGasEIP-1559 max fee
maxPriorityFeePerGasEIP-1559 priority fee

WalletUnsignedTransaction.Tron

Reserved for future use. Not currently supported by the backend.

Eip712TypedData / Eip712Field

Typed data structure and field definitions for EIP-712 signing.

TransactionReceipt

FieldDescription
transactionHashTransaction hash
blockHashBlock hash
blockNumberBlock number (hex string)
fromSender address
toRecipient address
gasUsedGas used (hex string)
effectiveGasPriceEffective gas price (hex string)
status"0x1" = success, "0x0" = failure
transactionIndexIndex within the block
typeTransaction type
logsJsonEvent logs as a JSON string
rawJsonFull raw receipt JSON

AddressNameEntry

FieldDescription
addressWallet address to label
nameLabel string (4–24 chars); empty string deletes the label

SelectedWallet

FieldDescription
addressSelected wallet address
indexAddress index

JsonRpcRequest

FieldDescription
idRequest ID (Long)
jsonrpcJSON-RPC version (e.g. "2.0")
methodRPC method name (e.g. "eth_call")
paramsJSON array string (e.g. ["0xabc","latest"])

AuthResult

FieldDescription
successWhether authentication succeeded
walletAddressResolved wallet address (may be empty)
userUserInfo? — OAuth user details
needsMigrationBoolean? — whether wallet migration is needed

UserInfo

FieldDescription
idInternal user ID
emailUser email
providerOAuth provider ("google", "apple")
accessTokenOAuth access token
idTokenOAuth ID token
subJWT subject

SDKUserInfo

FieldDescription
statusResponse status (e.g. "success")
dataSDKUserInfoData — provider and token details
loginTypeLogin type string
addressesList of wallet addresses

SDKUserInfoData fields: provider, accessToken, idToken, email, sub, providerSub

Convenience properties on SDKUserInfo: id, email, provider, accessToken, idToken, sub, providerSub (delegated from data).

WalletCheckResp

FieldDescription
resultWalletCheckResult: exists | migration_required | not_found

Errors

All SDK errors are variants of CROSSxError.

Auth errors

ErrorDescription
NotAuthenticatedNo active session; user must sign in
AuthFailedAuthentication failed (backend rejection or invalid token)
TokenExpiredAccess token is expired
SessionExpiredAccess token is unusable and token refresh failed (e.g. refresh token expired). Requires sign-out
OAuthFailedOAuth provider flow failed
AccountMismatchUser signed in with a different account than expected

User action

ErrorDescription
UserRejectedUser cancelled the confirmation dialog

Wallet errors

ErrorDescription
MigrationRequiredWallet requires migration and migrateAutomatically = false
WalletPasswordRequiredWallet password is not set; must call createWallet() first
WalletPasswordChangedWallet password was changed on another device
WalletInconsistentStateInternal wallet state is inconsistent
MigrationPinFailedMigration PIN verification failed
WalletPinFailedWallet PIN verification failed
InvalidPasswordWrong wallet password entered
PasswordLockedToo many wrong password attempts; check PasswordLocked.info for lockout details

Sign / send errors

ErrorDescription
SignFailedSigning operation failed
TransactionFailedTransaction was rejected or reverted
TimeoutOperation did not complete within the specified timeout

Other errors

ErrorDescription
NetworkErrorNetwork request failed
InvalidConfigSDK configuration is invalid
UnknownUnexpected error

Message strings may vary with SDK resources and locale.

Wallet gateway error codes

CodeDescription
-10026domain chainId mismatchdomain.chainId in the payload does not match the request chainId
-10040HMAC validation failed (missing X-HMAC-Signature header)
-10041HMAC validation failed (invalid X-HMAC-Signature header)