API Reference
Core SDK — API Reference
This page documents the public API surface of CROSSxSDK for JavaScript/TypeScript.
Factory
import { createCROSSxSDK } from '@nexus-cross/crossx-sdk-core'
const sdk = createCROSSxSDK(config: SDKConfig): CROSSxSDKCreates and returns a CROSSxSDK instance. This is the only way to instantiate the SDK — do not use new CROSSxSDK() directly.
Configuration Types
SDKConfig
SDKConfiginterface SDKConfig {
projectId: string
appName: string
useMockWallet?: boolean
logger?: LoggerPort
theme?: 'light' | 'dark'
autoDetectTheme?: boolean
themeTokens?: SDKThemeTokens
locale?: 'ko' | 'en' // default: 'en'
debug?: boolean
receiptPolling?: {
intervalMs?: number // default: 2000
timeoutMs?: number // default: 60000
}
migration?: {
allowSkip?: boolean // default: true
}
showConnectOtherWallets?: boolean // default: false
}| Field | Type | Required | Description |
|---|---|---|---|
projectId | string | Yes | Project ID from management console |
appName | string | Yes | Application name displayed in confirmation modals |
useMockWallet | boolean | No | Enable mock wallet for testing |
logger | LoggerPort | No | Custom logger for routing SDK logs |
theme | 'light' | 'dark' | No | Confirmation modal theme (default: 'light') |
autoDetectTheme | boolean | No | Auto-detect system dark mode via prefers-color-scheme (default: false) |
themeTokens | SDKThemeTokens | No | Per-mode color overrides |
locale | 'ko' | 'en' | No | Modal UI language (default: 'en') |
debug | boolean | No | Enable debug log output |
receiptPolling | object | No | { intervalMs?: number, timeoutMs?: number } |
migration | object | No | { allowSkip?: boolean } — controls migration UI behavior (default: { allowSkip: true }) |
showConnectOtherWallets | boolean | No | Show "Connect with Other Wallets" button in login modal (default: false). Emits connectExternalWallet event and throws EXTERNAL_WALLET_REQUESTED when clicked |
SDKThemeTokens
SDKThemeTokensinterface SDKThemeTokens {
light?: SDKColorOverrides
dark?: SDKColorOverrides
}SDKColorOverrides
SDKColorOverridesinterface SDKColorOverrides {
primary?: string
secondary?: string
onPrimary?: string
borderDefault?: string
borderSubtle?: string
textIconPrimary?: string
textIconSecondary?: string
textIconTertiary?: string
surfaceDefault?: string
surfaceSubtle?: string
bg?: string
error?: string
}Color format: CSS color string (e.g.
'#FF6B35','rgba(18,18,18,0.5)').
SignInOptions
SignInOptionsinterface SignInOptions {
provider?: 'google' | 'apple'
}SignOptions
SignOptionsinterface SignOptions {
index?: number
dappName?: string
accountName?: string
}Core API
initialize(opts?)
initialize(opts?)async initialize(opts?: { preferredWalletIndex?: number }): Promise<AuthResult | null>| Parameter | Type | Required | Description |
|---|---|---|---|
opts.preferredWalletIndex | number | No | Wallet derivation index to restore on session resume |
Returns: AuthResult if a prior session is restored, null if no session exists.
Initializes the SDK and restores a prior session from persistent storage if available. Must be called once at startup before any other SDK method. When a session is restored, the returned AuthResult reflects the user's previous sign-in state.
signIn(options?)
signIn(options?)async signIn(options?: SignInOptions): Promise<AuthResult>| Parameter | Type | Required | Description |
|---|---|---|---|
options.provider | 'google' | 'apple' | No | OAuth provider to use. If omitted, the SDK displays a provider selection modal. |
Returns: AuthResult
Opens the OAuth sign-in flow. If options.provider is not specified, a provider selection modal is displayed. On success, creates a session and returns auth state. Throws if the user cancels.
signInWithCreate(options?)
signInWithCreate(options?)async signInWithCreate(options?: SignInOptions): Promise<SignInWithCreateResult>| Parameter | Type | Required | Description |
|---|---|---|---|
options.provider | 'google' | 'apple' | No | OAuth provider to use |
Returns: SignInWithCreateResult
Signs in and automatically creates an embedded wallet if the user does not already have one. Also handles CROSSx wallet migration automatically. Use this method for most onboarding flows.
signInWithJWT(accessToken, refreshToken?)
signInWithJWT(accessToken, refreshToken?)async signInWithJWT(accessToken: string, refreshToken?: string): Promise<AuthResult>| Parameter | Type | Required | Description |
|---|---|---|---|
accessToken | string | Yes | JWT access token obtained from your backend or Firebase |
refreshToken | string | No | Optional refresh token for session renewal |
Returns: AuthResult
Authenticates using a pre-obtained JWT access token. Useful for React Native WebView scenarios where Firebase Auth is handled natively and the token is passed to the JS SDK. The JWT signature is verified via JWKS.
signOut()
signOut()async signOut(): Promise<void>Signs out the current user and clears the session from persistent storage. Emits an authChanged event with isAuthenticated: false.
isAuthenticated()
isAuthenticated()isAuthenticated(): booleanReturns: true if the user has an active authenticated session, false otherwise.
Synchronous check of the current auth state. Does not trigger a network request.
isLoggedIn()
isLoggedIn()isLoggedIn(): booleanAlias for isAuthenticated(). Returns the same value.
ensureLoggedIn()
ensureLoggedIn()async ensureLoggedIn(): Promise<boolean>Returns: true if the session is valid, false if a sign-in is needed.
Verifies that the current session is still valid (e.g. token not expired). Use before operations that require authentication.
getUserInfo()
getUserInfo()async getUserInfo(): Promise<SDKUserInfo>Returns: SDKUserInfo
Retrieves the authenticated user's profile including ID, email, login type, and wallet addresses. Throws AUTH_NOT_AUTHENTICATED if not signed in.
currentAddress
currentAddressget currentAddress: string | nullSynchronous getter returning the currently active wallet address, or null if not authenticated or no wallet is selected.
currentUserId
currentUserIdget currentUserId: string | nullSynchronous getter returning the authenticated user's ID (JWT sub claim), or null if not authenticated.
Address / Wallet
getAddress(index?)
getAddress(index?)async getAddress(index?: number): Promise<{ address: string; index: number } | null>| Parameter | Type | Required | Description |
|---|---|---|---|
index | number | No | Wallet derivation index. Defaults to the currently selected wallet index. |
Returns: { address: string; index: number } or null if no wallet exists at that index.
Returns the address for a specific HD wallet derivation index. If no index is specified, returns the active wallet's address.
getAddresses()
getAddresses()async getAddresses(): Promise<Array<{ address: string; index: number }>>Returns: Array of all wallet addresses for the current user, each with its derivation index.
Retrieves all HD wallet addresses derived for this user's account.
createWallet()
createWallet()async createWallet(): Promise<{ address: string }>Returns: { address: string } — the newly created wallet address.
Derives a new HD wallet address for the current user. Requires the user to be authenticated.
selectWallet(currentAddress?)
selectWallet(currentAddress?)async selectWallet(currentAddress?: string): Promise<{ address: string; index: number } | null>| Parameter | Type | Required | Description |
|---|---|---|---|
currentAddress | string | No | Address to mark as "currently selected" in the wallet selector modal |
Returns: { address: string; index: number } for the wallet the user selected, or null if the user dismisses the modal.
Opens the wallet selector modal, allowing the user to switch between multiple HD wallets. If currentAddress is provided, the matching wallet entry is highlighted with a "selected" tag.
Chain
getChains()
getChains()async getChains(): Promise<ChainInfo[]>Returns: Array of ChainInfo for all supported chains.
Returns all chains configured for the current project. Does not require authentication — only initialize() must have been called.
getChain(chainId)
getChain(chainId)async getChain(chainId: string): Promise<ChainInfo>| Parameter | Type | Required | Description |
|---|---|---|---|
chainId | string | Yes | CAIP-2 chain ID (e.g. 'eip155:612044') |
Returns: ChainInfo for the specified chain.
Returns configuration for a specific chain. Throws INVALID_CHAIN if chainId is not in CAIP-2 format, or CHAIN_NOT_SUPPORTED if the chain is not registered.
Signing
All signing methods display a user confirmation modal before executing.
signMessage(chainId, message, opts?)
signMessage(chainId, message, opts?)async signMessage(
chainId: string,
message: string,
opts?: SignOptions
): Promise<SignMessageResp>| Parameter | Type | Required | Description |
|---|---|---|---|
chainId | string | Yes | CAIP-2 chain ID (e.g. 'eip155:612044') |
message | string | Yes | Plain-text message to sign |
opts.index | number | No | Wallet derivation index |
opts.dappName | string | No | DApp name shown in the confirmation modal |
opts.accountName | string | No | Account label shown in the confirmation modal |
Returns: SignMessageResp
Signs a UTF-8 message using EIP-191 personal sign. Displays a confirmation modal showing the message content and signer address before proceeding.
signTypedData(chainId, typedData, opts?)
signTypedData(chainId, typedData, opts?)async signTypedData(
chainId: string,
typedData: unknown,
opts?: SignOptions
): Promise<SignTypedDataResp>| Parameter | Type | Required | Description |
|---|---|---|---|
chainId | string | Yes | CAIP-2 chain ID. The numeric part must match typedData.domain.chainId. |
typedData | unknown | Yes | EIP-712 typed data object with domain.chainId |
opts | SignOptions | No | Wallet index and display options |
Returns: SignTypedDataResp
Signs EIP-712 typed structured data for on-chain use. Requires typedData.domain.chainId to match the numeric part of chainId. Throws TYPED_DATA_CHAIN_ID_MISMATCH on mismatch. For typed data without a chain ID, use signTypedDataOffchain().
signTypedDataOffchain(typedData, opts?)
signTypedDataOffchain(typedData, opts?)async signTypedDataOffchain(
typedData: unknown,
opts?: SignOptions
): Promise<SignTypedDataResp>| Parameter | Type | Required | Description |
|---|---|---|---|
typedData | unknown | Yes | EIP-712 typed data object without domain.chainId |
opts | SignOptions | No | Wallet index and display options |
Returns: SignTypedDataResp with chainId: '0'
Signs EIP-712 typed data for off-chain use cases (e.g. permit signatures, order books). Use when typedData.domain.chainId is absent or zero.
signTransaction(chainId, tx, opts?)
signTransaction(chainId, tx, opts?)async signTransaction(
chainId: string,
tx: EvmTransactionRequest,
opts?: SignOptions
): Promise<SignTxResp>| Parameter | Type | Required | Description |
|---|---|---|---|
chainId | string | Yes | CAIP-2 chain ID |
tx | EvmTransactionRequest | Yes | Transaction to sign. tx.from must be non-empty. |
opts | SignOptions | No | Wallet index and display options |
Returns: SignTxResp
Signs a transaction without broadcasting it. Gas fields (gasLimit, gasPrice / maxFeePerGas) are resolved automatically if not provided. Returns the RLP-encoded signed transaction and its hash.
Transactions
sendTransaction(chainId, tx, opts?)
sendTransaction(chainId, tx, opts?)async sendTransaction(
chainId: string,
tx: EvmTransactionRequest,
opts?: SignOptions
): Promise<SendTxResp>| Parameter | Type | Required | Description |
|---|---|---|---|
chainId | string | Yes | CAIP-2 chain ID |
tx | EvmTransactionRequest | Yes | Transaction to broadcast. tx.from must be non-empty. |
opts | SignOptions | No | Wallet index and display options |
Returns: SendTxResp
Signs and broadcasts a transaction. Displays a confirmation modal before signing. Gas fields are auto-resolved if not provided. Returns immediately after broadcast with status: 'pending'.
sendTransactionWithWaitForReceipt(chainId, tx, opts?)
sendTransactionWithWaitForReceipt(chainId, tx, opts?)async sendTransactionWithWaitForReceipt(
chainId: string,
tx: EvmTransactionRequest,
opts?: SignOptions & { intervalMs?: number; timeoutMs?: number }
): Promise<TransactionWithReceipt>| Parameter | Type | Required | Description |
|---|---|---|---|
chainId | string | Yes | CAIP-2 chain ID |
tx | EvmTransactionRequest | Yes | Transaction to broadcast |
opts.intervalMs | number | No | Receipt polling interval in ms (default: from SDKConfig.receiptPolling, fallback 2000) |
opts.timeoutMs | number | No | Polling timeout in ms (default: from SDKConfig.receiptPolling, fallback 60000) |
Returns: TransactionWithReceipt
Signs, broadcasts, and waits for the transaction receipt. Displays a transaction progress modal showing pending and mined states. Polling interval and timeout default to the values set in SDKConfig.receiptPolling.
getTransactionReceipt(txHash, chainId)
getTransactionReceipt(txHash, chainId)async getTransactionReceipt(txHash: string, chainId: string): Promise<TransactionReceipt | null>| Parameter | Type | Required | Description |
|---|---|---|---|
txHash | string | Yes | Transaction hash |
chainId | string | Yes | CAIP-2 chain ID |
Returns: TransactionReceipt if mined, null if still pending.
Fetches the receipt for a specific transaction hash. Returns null if the transaction has not been mined yet.
waitForTxAndGetReceipt(txHash, chainId, opts?)
waitForTxAndGetReceipt(txHash, chainId, opts?)async waitForTxAndGetReceipt(
txHash: string,
chainId: string,
opts?: { intervalMs?: number; timeoutMs?: number }
): Promise<TransactionReceipt>| Parameter | Type | Required | Description |
|---|---|---|---|
txHash | string | Yes | Transaction hash to poll |
chainId | string | Yes | CAIP-2 chain ID |
opts.intervalMs | number | No | Polling interval in ms (default: 2000) |
opts.timeoutMs | number | No | Timeout in ms (default: 60000) |
Returns: TransactionReceipt
Polls for a transaction receipt until it is mined or the timeout is reached. Throws if the timeout expires before the receipt is available.
Gas
getGasPrice(chainId)
getGasPrice(chainId)async getGasPrice(chainId: string): Promise<string>| Parameter | Type | Required | Description |
|---|---|---|---|
chainId | string | Yes | CAIP-2 chain ID |
Returns: Hex-encoded gas price in Wei (e.g. '0x3b9aca00').
Fetches the current gas price via eth_gasPrice. Use for legacy (pre-EIP-1559) transactions. For EIP-1559 chains, prefer getMaxPriorityFeePerGas() and getBaseFeePerGas().
estimateGas(tx, chainId)
estimateGas(tx, chainId)async estimateGas(tx: EvmTransactionRequest, chainId: string): Promise<string>| Parameter | Type | Required | Description |
|---|---|---|---|
tx | EvmTransactionRequest | Yes | Transaction to estimate |
chainId | string | Yes | CAIP-2 chain ID |
Returns: Hex-encoded estimated gas limit (e.g. '0x5208').
Calls eth_estimateGas on the specified chain. The estimate reflects gas required at the current block state. Throws GAS_ESTIMATION_FAILED if the call reverts.
getBaseFeePerGas(chainId)
getBaseFeePerGas(chainId)async getBaseFeePerGas(chainId: string): Promise<string | null>| Parameter | Type | Required | Description |
|---|---|---|---|
chainId | string | Yes | CAIP-2 chain ID |
Returns: Hex-encoded base fee in Wei, or null on chains that do not support EIP-1559.
Fetches the base fee per gas from the latest block header. Returns null on legacy chains.
getMaxPriorityFeePerGas(chainId)
getMaxPriorityFeePerGas(chainId)async getMaxPriorityFeePerGas(chainId: string): Promise<string>| Parameter | Type | Required | Description |
|---|---|---|---|
chainId | string | Yes | CAIP-2 chain ID |
Returns: Hex-encoded EIP-1559 priority fee (tip) in Wei.
Fetches the suggested miner priority fee via eth_maxPriorityFeePerGas. Use with getBaseFeePerGas() to construct EIP-1559 transaction fee fields.
Balance / Nonce / RPC
getBalance(chainId)
getBalance(chainId)async getBalance(chainId: string): Promise<{ wei: string; formatted: string; chainId: string }>| Parameter | Type | Required | Description |
|---|---|---|---|
chainId | string | Yes | CAIP-2 chain ID |
Returns:
| Field | Type | Description |
|---|---|---|
wei | string | Raw balance in Wei as a decimal string |
formatted | string | Human-readable balance in native token units (e.g. '1.5') |
chainId | string | CAIP-2 chain ID the balance was fetched from |
Fetches the native token balance for the current wallet on the specified chain.
getNonce(chainId)
getNonce(chainId)async getNonce(chainId: string): Promise<number>| Parameter | Type | Required | Description |
|---|---|---|---|
chainId | string | Yes | CAIP-2 chain ID |
Returns: Current transaction count (nonce) as a number.
Returns the number of transactions sent from the current wallet address via eth_getTransactionCount. Unlike the mobile SDKs, this returns a number rather than a hex string.
walletRpc(method, params, chainId)
walletRpc(method, params, chainId)async walletRpc(method: string, params: any[], chainId: string): Promise<any>| Parameter | Type | Required | Description |
|---|---|---|---|
method | string | Yes | JSON-RPC method name (e.g. 'eth_call') |
params | any[] | Yes | Method parameters array |
chainId | string | Yes | CAIP-2 chain ID to send the request to |
Returns: JSON-RPC result.
Sends a raw JSON-RPC read-only request to the specified chain's RPC endpoint. Intended for read operations (eth_call, eth_getBalance, eth_getCode, etc.). Do not use for signing or sending transactions.
Provider
getProvider(chainId)
getProvider(chainId)getProvider(chainId: string): CROSSxEthereumProvider| Parameter | Type | Required | Description |
|---|---|---|---|
chainId | string | Yes | CAIP-2 chain ID (e.g. 'eip155:612044') |
Returns: CROSSxEthereumProvider — an EIP-1193 compatible provider.
Returns an EIP-1193 provider bound to the specified chain. Compatible with ethers.js v6, viem, and other libraries that accept an EIP-1193 provider.
const provider = sdk.getProvider('eip155:612044')
// ethers.js v6
const ethersProvider = new ethers.BrowserProvider(provider)
// viem
const client = createWalletClient({ transport: custom(provider) })Theme & Locale
applyTheme(themeMode?, themeTokens?)
applyTheme(themeMode?, themeTokens?)applyTheme(themeMode?: 'light' | 'dark', themeTokens?: SDKThemeTokens): void| Parameter | Type | Required | Description |
|---|---|---|---|
themeMode | 'light' | 'dark' | No | Theme mode to apply |
themeTokens | SDKThemeTokens | No | Color token overrides for light/dark modes |
Changes the confirmation modal theme at runtime. Takes effect on the next modal open. Useful for responding to system dark mode changes dynamically.
applyLocale(locale?)
applyLocale(locale?)applyLocale(locale?: 'ko' | 'en'): void| Parameter | Type | Required | Description |
|---|---|---|---|
locale | 'ko' | 'en' | No | Language for modal UI text |
Changes the confirmation modal language at runtime. Takes effect on the next modal open.
sdk.applyLocale('ko')
sdk.applyLocale('en')PIN Management
setPin(pin)
setPin(pin)setPin(pin: string): void| Parameter | Type | Required | Description |
|---|---|---|---|
pin | string | Yes | PIN to cache in memory |
Caches the user's PIN in memory so that signing flows can proceed without displaying a PIN input modal. The PIN is kept only in memory and cleared on clearPin() or signOut().
clearPin()
clearPin()clearPin(): voidClears the cached PIN from memory. Subsequent signing flows that require a PIN will prompt the user via the SDK modal.
hasPin()
hasPin()hasPin(): booleanReturns: true if a PIN is currently cached in memory, false otherwise.
Checks whether a PIN is cached without exposing the PIN value.
changePin(oldPin, newPin)
changePin(oldPin, newPin)async changePin(oldPin: string, newPin: string): Promise<void>| Parameter | Type | Required | Description |
|---|---|---|---|
oldPin | string | Yes | Current PIN |
newPin | string | Yes | New PIN to set |
Changes the user's PIN on the server. The new PIN must satisfy format requirements (no sequential or repeated digit patterns). Throws PIN_WRONG if oldPin is incorrect, or PIN_INVALID / PIN_REPEATED_PATTERN if the new PIN is rejected.
Migration
migrateWallet(pin)
migrateWallet(pin)async migrateWallet(pin: string): Promise<MigrateResult>| Parameter | Type | Required | Description |
|---|---|---|---|
pin | string | Yes | 4-digit PIN used during original CROSSx wallet creation |
Returns: MigrateResult
Migrates a legacy CROSSx wallet to an Embedded Wallet using the original 4-digit PIN. After migration, the wallet is accessible via the standard wallet API. Throws MIGRATION_FAILED on failure or MIGRATION_PIN_LOCKED after too many incorrect PIN attempts.
Events
CROSSxSDK extends TypedEventEmitter<SDKEventMap> and supports typed event subscription.
on(event, listener)
on(event, listener)on(event: string, listener: Function): () => voidSubscribes to an SDK event. Returns an unsubscribe function.
off(event, listener)
off(event, listener)off(event: string, listener: Function): voidRemoves an event listener.
Event Types
| Event | Payload | Description |
|---|---|---|
authChanged | { isAuthenticated: boolean, address: string | null, userId: string | null } | Fired when auth state changes (sign in / sign out) |
addressChanged | { address: string, index: number } | Fired when the active wallet address changes |
initialized | { restored: boolean } | Fired when SDK initialization completes |
connectExternalWallet | Record<string, never> (empty object) | Fired when user clicks "Connect with Other Wallets" |
const unsub = sdk.on('authChanged', (event) => {
console.log(event.isAuthenticated, event.address)
})
// Cleanup
unsub()Lifecycle
dispose()
dispose()dispose(): voidCleans up SDK resources including event listeners and internal state. The instance cannot be used after this call. Call this when unmounting an SDK host component or tearing down the application.
Response Types
AuthResult
AuthResult| Field | Type | Description |
|---|---|---|
success | boolean | Authentication success flag |
address | string? | Wallet address (if available) |
user | UserInfo? | User profile |
error | string? | Error message on failure |
needsMigration | boolean? | CROSSx backup found |
tokenSignatureVerified | boolean? | JWT verified via JWKS |
SignInWithCreateResult
SignInWithCreateResultExtends AuthResult with additional fields:
| Field | Type | Description |
|---|---|---|
addresses | Array<{ address: string; index: number }> | Full wallet address list |
SDKUserInfo
SDKUserInfo| Field | Type | Description |
|---|---|---|
id | string | User identifier (JWT sub) |
email | string? | User email |
loginType | string? | 'google' | 'apple' |
addresses | string[] | Wallet address list |
tokenSignatureVerified | boolean | JWT verified via JWKS |
ChainInfo
ChainInfo| Field | Type | Description |
|---|---|---|
chainId | string | CAIP-2 chain ID (e.g. eip155:612044) |
rpcUrl | string | JSON-RPC endpoint URL |
EvmTransactionRequest
EvmTransactionRequest| Field | Type | Description |
|---|---|---|
from | string | Sender address |
to | string | Recipient address |
value | string? | Hex wei value |
data | string? | Calldata hex |
gasLimit | string? | Hex gas limit |
gasPrice | string? | Legacy gas price |
maxFeePerGas | string? | EIP-1559 max fee |
maxPriorityFeePerGas | string? | EIP-1559 priority fee |
nonce | number? | Nonce (number) |
chainId | number? | Numeric chain ID |
SignMessageResp
SignMessageResp| Field | Type | Description |
|---|---|---|
chainId | string | CAIP-2 chain ID |
signature | string | Signature hex |
message | string | Original message |
address | string | Signer address |
SignTypedDataResp
SignTypedDataResp| Field | Type | Description |
|---|---|---|
chainId | string | CAIP-2 chain ID (on-chain) or '0' (off-chain) |
signature | string | EIP-712 signature hex |
address | string | Signer address |
SignTxResp
SignTxResp| Field | Type | Description |
|---|---|---|
chainId | string | CAIP-2 chain ID |
signedTx | string | RLP-encoded signed tx hex |
txHash | string | Transaction hash |
SendTxResp
SendTxResp| Field | Type | Description |
|---|---|---|
chainId | string | CAIP-2 chain ID |
txHash | string | Broadcasted tx hash |
status | string | 'pending' | 'success' | 'failed' |
TransactionWithReceipt
TransactionWithReceipt| Field | Type | Description |
|---|---|---|
chainId | string | CAIP-2 chain ID |
txHash | string | Transaction hash |
receipt | TransactionReceipt | Mined receipt |
TransactionReceipt
TransactionReceipt| Field | Type | Description |
|---|---|---|
transactionHash | string | Transaction hash |
blockHash | string | Block hash |
blockNumber | string | Block number (hex) |
from | string | Sender |
to | string | null | Recipient (null for contract creation) |
gasUsed | string | Gas used (hex) |
effectiveGasPrice | string | Gas price (hex) |
status | '0x1' | '0x0' | Success or reverted |
logs | any[] | Event logs |
transactionIndex | string | Index in block |
type | string | Transaction type |
MigrateResult
MigrateResult| Field | Type | Description |
|---|---|---|
address | string | Migrated wallet address |
Error Handling
import { CROSSxError, ErrorCode } from '@nexus-cross/crossx-sdk-core'
try {
await sdk.signTransaction(chainId, tx)
} catch (error) {
if (error instanceof CROSSxError) {
console.log(error.code) // ErrorCode enum
console.log(error.message) // Human-readable message
console.log(error.details) // Original error
}
}Error Codes
| Code | Description |
|---|---|
AUTH_NOT_INITIALIZED | SDK not initialized — call initialize() first |
AUTH_FAILED | Sign in failed |
AUTH_TOKEN_INVALID | Auth token is invalid |
AUTH_TOKEN_EXPIRED | Auth token has expired |
AUTH_NOT_AUTHENTICATED | Not authenticated — call signIn() first |
ALREADY_AUTHENTICATED | Already authenticated — sign out first |
WALLET_NOT_FOUND | Wallet not found |
WALLET_CREATION_FAILED | Wallet creation failed |
WALLET_INCONSISTENT_STATE | Wallet state inconsistency detected |
SIGN_FAILED | Signing failed |
SIGN_REJECTED | Signing rejected |
TX_FAILED | Transaction failed |
TX_REJECTED | Transaction rejected |
TX_INVALID_PARAMS | Invalid transaction parameters |
USER_REJECTED | User rejected in confirmation modal |
SIGNATURE_SIGNER_MISMATCH | ecrecover address mismatch |
GAS_ESTIMATION_FAILED | Gas estimation failed (eth_gasPrice / eth_estimateGas) |
TYPED_DATA_CHAIN_ID_MISMATCH | EIP-712 domain.chainId mismatch with path chainId |
NETWORK_ERROR | Network communication error |
NETWORK_NOT_CONFIGURED | Network adapter not configured |
INVALID_CHAIN | Invalid chain ID format |
CHAIN_NOT_SUPPORTED | Chain not supported / not registered |
CHAIN_ADAPTER_NOT_FOUND | Chain adapter not found |
PREPARE_FAILED | Pre-sign/send preparation failed |
PREPARE_EXPIRED | Prepared action expired |
PREPARE_MISMATCH | Prepared action mismatch |
MIGRATION_FAILED | Wallet migration failed |
MIGRATION_BACKUP_EXISTS | CROSSx backup found, migration required |
MIGRATION_PIN_LOCKED | PIN locked during migration — too many attempts |
PIN_NOT_SET | PIN is required but not set |
PIN_WRONG | Incorrect PIN entered |
PIN_INVALID | PIN format is invalid (sequential digits not allowed) |
PIN_REPEATED_PATTERN | PIN repeated digit pattern not allowed (Gateway -10032) |
PIN_CANCELLED | User cancelled PIN input |
EXTERNAL_WALLET_REQUESTED | User requested external wallet connection via "Connect with Other Wallets" button |
PIN_LOCKED | PIN locked due to too many failed attempts |
BROADCAST_FAILED | Transaction broadcast failed (-10007) |
GATEWAY_INTERNAL_ERROR | Gateway internal error (-10006), retry recommended |
GATEWAY_LOCK_CONFLICT | Lock conflict (-10008), retry recommended |
PROJECT_ID_MISSING | X-Project-Id header missing (gateway -10023) |
ORIGIN_NOT_ALLOWED | Origin not in allowed list (gateway -10024) |
APP_IDENTIFIER_MISSING | App identifier missing (gateway -10024) |
INVALID_APP_TYPE | Invalid X-App-Type value (gateway -10025) |
PROJECT_NOT_REGISTERED | Project not whitelisted (gateway -10022) |
INVALID_CONFIG | Invalid SDK configuration |
UNKNOWN_ERROR | Unknown error |
Chain ID Constants
import { ChainId } from '@nexus-cross/crossx-sdk-core'| Constant | Value |
|---|---|
ChainId.CROSS_MAINNET | 'eip155:612055' |
ChainId.CROSS_TESTNET | 'eip155:612044' |
ChainId.BSC_MAINNET | 'eip155:56' |
ChainId.BSC_TESTNET | 'eip155:97' |
ChainId.RONIN_MAINNET | 'eip155:2020' |
ChainId.RONIN_SAIGON | 'eip155:202601' |
Public Type Exports
import type {
SDKConfig,
SDKThemeTokens,
SDKColorOverrides,
AuthResult,
SignInWithCreateResult,
SignInOptions,
SignOptions,
SDKUserInfo,
UserInfo,
EvmTransactionRequest,
SignMessageResp,
SignTypedDataResp,
SignTxResp,
SendTxResp,
TransactionWithReceipt,
MigrateResult,
ChainInfo,
ChainIdValue,
AddressInfo,
SDKEventMap,
AuthChangedEvent,
AddressChangedEvent,
InitializedEvent,
ConnectExternalWalletEvent,
PrepareAction,
PrepareContext,
PrepareResult,
} from '@nexus-cross/crossx-sdk-core'
import {
createCROSSxSDK,
CROSSxSDK,
CROSSxEthereumProvider,
ChainId,
CROSSxError,
ErrorCode,
} from '@nexus-cross/crossx-sdk-core'