API Reference
Android SDK API Reference
Public CROSSxSDK API reference.
Configuration
SDKConfig
SDKConfigSDK 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)
)| Parameter | Type | Description |
|---|---|---|
projectId | String | CROSSx project identifier |
appId | String | Gradle applicationId including any flavor suffix. Omit to derive from context |
appName | String | Host app display name shown in SDK UI |
appVersion | String | App version string sent as X-App-Version header (e.g. "1.0.0"). Defaults to "". Auto-populated from PackageManager when using the convenience constructor |
callbackScheme | String | OAuth deep-link scheme. Use SDKConfig.defaultScheme(projectId) |
theme | SDKThemeMode | Initial theme mode (default: Light) |
themeTokens | SDKThemeTokens | Color token overrides per theme |
logger | LoggerPort? | Optional logger for SDK debug output |
SDKSignInProvider
SDKSignInProviderSelects 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
SDKThemeMode / SDKThemeTokensenum 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
SDKColorOverridesPer-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
configval config: SDKConfigRead-only configuration provided at construction.
handleUrl()
handleUrl()fun handleUrl(url: String): BooleanRoutes 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()
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
nullis returned. - Call this on app start before checking
isLoggedIn().
Returns AuthResult? — restored session info, or null if no session could be restored.
applyTheme()
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.
| Parameter | Default | Description |
|---|---|---|
themeMode | config.theme | Light / Dark / System |
themeTokens | config.themeTokens | Color token overrides |
signIn()
signIn()suspend fun signIn(provider: SDKSignInProvider = SDKSignInProvider.All): AuthResultLaunches 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.
| Parameter | Default | Description |
|---|---|---|
provider | All | OAuth provider to use |
Returns AuthResult — auth state and user info.
signInAgain()
signInAgain()suspend fun signInAgain(): AuthResultRe-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()
signInWithJWT()suspend fun signInWithJWT(
idToken: String,
providerSub: String? = null,
provider: String? = null
): AuthResultSigns 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.
| Parameter | Default | Description |
|---|---|---|
idToken | — | Firebase ID Token |
providerSub | null | OAuth provider's unique user ID (extracted from idToken if not provided) |
provider | null | OAuth 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()
signInWithCreate()suspend fun signInWithCreate(provider: SDKSignInProvider = SDKSignInProvider.All): AuthResultSame 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.
| Parameter | Default | Description |
|---|---|---|
provider | All | OAuth provider to use |
Returns AuthResult with the resolved wallet address.
signOut()
signOut()suspend fun signOut()Clears the local session, access/refresh tokens, and OAuth state. Subsequent calls to isLoggedIn() will return false.
refreshToken()
refreshToken()suspend fun refreshToken(): StringForces 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()
isLoggedIn()fun isLoggedIn(): BooleanReturns 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()
ensureLoggedIn()suspend fun ensureLoggedIn(): BooleanEnsures the current session is usable:
- If the local access token is still valid, returns
trueimmediately. - Otherwise attempts session restore and refresh via
initialize(). - Returns
falsewhen no restorable session exists.
Returns Boolean — true if a valid session is available, false if the user must sign in.
getUserInfo()
getUserInfo()suspend fun getUserInfo(): SDKUserInfoBuilds 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()
canUseBiometric()fun canUseBiometric(): BooleanReturns true if biometric hardware (fingerprint, face) is available and enrolled on the device.
isBiometricEnabled()
isBiometricEnabled()fun isBiometricEnabled(): BooleanReturns true if biometric unlock is currently enabled for the current user's wallet.
setBiometricEnabled()
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.
| Parameter | Description |
|---|---|
enabled | true to enable biometric unlock, false to disable |
Addresses / Wallet
getAddress()
getAddress()suspend fun getAddress(index: Int? = null): GetAddressRespReturns the wallet address at the given index. Pass null (default) to get the first/default address.
| Parameter | Default | Description |
|---|---|---|
index | null | Address index; null = first address |
getAddresses()
getAddresses()suspend fun getAddresses(): GetAddressesRespReturns all wallet addresses associated with the current user.
setAddressNames()
setAddressNames()suspend fun setAddressNames(names: List<AddressNameEntry>): UnitBulk sets or deletes address labels.
namesmust contain at most 10 entries.- Each non-empty
namemust be 4–24 characters and must not contain: `< > " ' ; \ $ & | `` - An empty string for
AddressNameEntry.namedeletes 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()
selectWallet()suspend fun selectWallet(activity: Activity, currentAddress: String? = null): SelectedWalletPresents a wallet selection UI to the user.
| Parameter | Default | Description |
|---|---|---|
activity | — | Host Activity for the modal |
currentAddress | null | Address to pre-select; null for no pre-selection |
Returns SelectedWallet with the chosen address and index.
checkWallet()
checkWallet()suspend fun checkWallet(): WalletCheckRespQueries the server for the current wallet state without creating or modifying any wallet. Useful to branch logic before calling createWallet().
Returns WalletCheckResp — result is one of exists | migration_required | not_found.
createWallet()
createWallet()suspend fun createWallet(migrateAutomatically: Boolean = true): CreateWalletRespCreates a new wallet or migrates an existing one, with UI for password/PIN entry.
| Parameter | Default | Description |
|---|---|---|
migrateAutomatically | true | When 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— throwsCROSSxError.MigrationRequired.not_found— creates a new wallet and returns the address.
Returns CreateWalletResp with the resolved address.
The public
crossx-sdk-coreartifact 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()
signMessage()suspend fun signMessage(
activity: Activity,
message: String,
chainId: String,
from: String? = null,
dappName: String = "",
accountName: String = "Account"
): SignMessageRespShows a confirmation dialog and signs a plain-text message with the user's wallet.
| Parameter | Default | Description |
|---|---|---|
activity | — | Host Activity for the confirmation UI |
message | — | Plain text message to sign |
chainId | — | CAIP-2 chain identifier (e.g. eip155:1) |
from | null | Signing 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
signTypedData() — JSON stringsuspend fun signTypedData(
activity: Activity,
typedDataJson: String,
chainId: String,
from: String? = null,
dappName: String = "",
accountName: String = "Account"
): SignTypedDataRespShows 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
signTypedData() — Eip712TypedData objectsuspend fun signTypedData(
activity: Activity,
typedData: Eip712TypedData,
chainId: String,
from: String? = null,
dappName: String = "",
accountName: String = "Account"
): SignTypedDataRespSame as above, but accepts a pre-parsed Eip712TypedData object instead of a JSON string.
signTypedDataOffchain()
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"
): SignTypedDataRespSigns 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()
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
): SignTxRespShows 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.
| Parameter | Default | Description |
|---|---|---|
networkName | null | Human-readable network name shown in the confirmation UI |
estimatedFee | null | Fee string shown in the confirmation UI |
amount | null | Amount string shown in the confirmation UI |
sendTransaction()
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
): SendTxRespShows a confirmation dialog, signs, and broadcasts the transaction to the network.
sendTransactionWithWaitForReceipt()
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
): TransactionReceiptSame as sendTransaction() but also polls for the on-chain transaction receipt before returning. Available for both UnsignedTx and WalletUnsignedTransaction.
| Parameter | Default | Description |
|---|---|---|
timeoutMs | 30_000 | Maximum time to wait for receipt (ms) |
pollIntervalMs | 1_000 | Polling interval (ms) |
Throws CROSSxError.Timeout if the receipt is not confirmed within timeoutMs.
RPC / Helpers
walletRpc()
walletRpc()suspend fun walletRpc(request: JsonRpcRequest, chainId: String): StringGeneric 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()
getBalance()suspend fun getBalance(
address: String,
chainId: String,
blockTag: String = "latest"
): StringCalls eth_getBalance(address, blockTag) against the resolved chain RPC URL.
| Parameter | Default | Description |
|---|---|---|
address | — | EVM wallet address |
chainId | — | CAIP-2 chain identifier |
blockTag | "latest" | Block tag ("latest", "pending", etc.) |
Returns hex string balance in wei, e.g. "0x0".
getNonce()
getNonce()suspend fun getNonce(
address: String,
chainId: String,
blockTag: String = "pending"
): StringCalls eth_getTransactionCount(address, blockTag) against the resolved chain RPC URL. Use "pending" (default) to include pending transactions — recommended before signing or sending.
| Parameter | Default | Description |
|---|---|---|
address | — | EVM wallet address |
chainId | — | CAIP-2 chain identifier |
blockTag | "pending" | Block tag ("pending" recommended for pre-sign nonce) |
Returns hex string nonce, e.g. "0x0".
waitForTxAndGetReceipt()
waitForTxAndGetReceipt()suspend fun waitForTxAndGetReceipt(
txHash: String,
chainId: String,
timeoutMs: Long = 30_000,
pollIntervalMs: Long = 1_000
): TransactionReceiptPolls 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.
| Parameter | Default | Description |
|---|---|---|
txHash | — | Transaction hash to wait for |
chainId | — | CAIP-2 chain identifier |
timeoutMs | 30_000 | Maximum wait time (ms) |
pollIntervalMs | 1_000 | Polling 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)
signMessage() (legacy)suspend fun signMessage(message: String, networkId: NetworkId): SignatureResultsendTransaction() (legacy)
sendTransaction() (legacy)suspend fun sendTransaction(params: TransactionParams): TransactionResultTypes
UnsignedTx
UnsignedTx| Field | Description |
|---|---|
chainId | CAIP-2 chain identifier |
from | Sender address |
to | Recipient address |
value | ETH value (hex string) |
data | Call data (hex string) |
nonce | Transaction nonce (hex string) |
gasLimit | Gas limit (hex string) |
gasPrice | Gas price for legacy transactions (hex string) |
maxFeePerGas | EIP-1559 max fee (hex string) |
maxPriorityFeePerGas | EIP-1559 priority fee (hex string) |
WalletUnsignedTransaction.EvmEip155
WalletUnsignedTransaction.EvmEip155| Field | Description |
|---|---|
chainId | CAIP-2 chain identifier |
from | Sender address |
to | Recipient address |
value | ETH value (hex string) |
data | Call data (hex string) |
nonce | Transaction nonce |
gasLimit | Gas limit |
gasPrice | Gas price for legacy transactions |
maxFeePerGas | EIP-1559 max fee |
maxPriorityFeePerGas | EIP-1559 priority fee |
WalletUnsignedTransaction.Tron
WalletUnsignedTransaction.TronReserved for future use. Not currently supported by the backend.
Eip712TypedData / Eip712Field
Eip712TypedData / Eip712FieldTyped data structure and field definitions for EIP-712 signing.
TransactionReceipt
TransactionReceipt| Field | Description |
|---|---|
transactionHash | Transaction hash |
blockHash | Block hash |
blockNumber | Block number (hex string) |
from | Sender address |
to | Recipient address |
gasUsed | Gas used (hex string) |
effectiveGasPrice | Effective gas price (hex string) |
status | "0x1" = success, "0x0" = failure |
transactionIndex | Index within the block |
type | Transaction type |
logsJson | Event logs as a JSON string |
rawJson | Full raw receipt JSON |
AddressNameEntry
AddressNameEntry| Field | Description |
|---|---|
address | Wallet address to label |
name | Label string (4–24 chars); empty string deletes the label |
SelectedWallet
SelectedWallet| Field | Description |
|---|---|
address | Selected wallet address |
index | Address index |
JsonRpcRequest
JsonRpcRequest| Field | Description |
|---|---|
id | Request ID (Long) |
jsonrpc | JSON-RPC version (e.g. "2.0") |
method | RPC method name (e.g. "eth_call") |
params | JSON array string (e.g. ["0xabc","latest"]) |
AuthResult
AuthResult| Field | Description |
|---|---|
success | Whether authentication succeeded |
walletAddress | Resolved wallet address (may be empty) |
user | UserInfo? — OAuth user details |
needsMigration | Boolean? — whether wallet migration is needed |
UserInfo
UserInfo| Field | Description |
|---|---|
id | Internal user ID |
email | User email |
provider | OAuth provider ("google", "apple") |
accessToken | OAuth access token |
idToken | OAuth ID token |
sub | JWT subject |
SDKUserInfo
SDKUserInfo| Field | Description |
|---|---|
status | Response status (e.g. "success") |
data | SDKUserInfoData — provider and token details |
loginType | Login type string |
addresses | List 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
WalletCheckResp| Field | Description |
|---|---|
result | WalletCheckResult: exists | migration_required | not_found |
Errors
All SDK errors are variants of CROSSxError.
Auth errors
| Error | Description |
|---|---|
NotAuthenticated | No active session; user must sign in |
AuthFailed | Authentication failed (backend rejection or invalid token) |
TokenExpired | Access token is expired |
SessionExpired | Access token is unusable and token refresh failed (e.g. refresh token expired). Requires sign-out |
OAuthFailed | OAuth provider flow failed |
AccountMismatch | User signed in with a different account than expected |
User action
| Error | Description |
|---|---|
UserRejected | User cancelled the confirmation dialog |
Wallet errors
| Error | Description |
|---|---|
MigrationRequired | Wallet requires migration and migrateAutomatically = false |
WalletPasswordRequired | Wallet password is not set; must call createWallet() first |
WalletPasswordChanged | Wallet password was changed on another device |
WalletInconsistentState | Internal wallet state is inconsistent |
MigrationPinFailed | Migration PIN verification failed |
WalletPinFailed | Wallet PIN verification failed |
InvalidPassword | Wrong wallet password entered |
PasswordLocked | Too many wrong password attempts; check PasswordLocked.info for lockout details |
Sign / send errors
| Error | Description |
|---|---|
SignFailed | Signing operation failed |
TransactionFailed | Transaction was rejected or reverted |
Timeout | Operation did not complete within the specified timeout |
Other errors
| Error | Description |
|---|---|
NetworkError | Network request failed |
InvalidConfig | SDK configuration is invalid |
Unknown | Unexpected error |
Message strings may vary with SDK resources and locale.
Wallet gateway error codes
| Code | Description |
|---|---|
-10026 | domain chainId mismatch — domain.chainId in the payload does not match the request chainId |
-10040 | HMAC validation failed (missing X-HMAC-Signature header) |
-10041 | HMAC validation failed (invalid X-HMAC-Signature header) |