crossx-20-js-unity
CROSSx Unity Skill
Documentation
Instructions
Identify the request category first, then make the smallest C# changes that fit the existing Unity project structure.
Treat the CROSSx Unity documentation linked above as the primary source for SDK usage, integration flow, and sample patterns.
If the bundled Unity docs do not fully answer the question or the latest SDK behavior is unclear, prefer the official cross MCP server before unrelated documentation sources.
File Discovery
Before editing, find the existing integration points for package setup, deep link callback, SDK creation, authentication flow, and wallet-related actions.
Check these first when they exist:
Packages/manifest.json(UPM dependency setup)Assets/Plugins/Android/AndroidManifest.xml(deep link intent filter)GameManageror other MonoBehaviour holding SDK initializationUIDocumentsetup for confirmation UI- Existing auth, wallet, settings, or blockchain-related MonoBehaviours
Prefer extending existing integration points over introducing new MonoBehaviours or architectural layers.
Request Classification
Classify each request into one or more of these categories before writing code:
- SDK setup: UPM install,
SDKConfigvalues,CrossyWalletSDKFactory.Create, deep link registration (Android, iOS, Windows) - Authentication: login provider (
SDKLoginProvider),SignInAsync/SignInWithCreateAsync, session restore viaInitializeAsync,EnsureLoggedInAsync, sign-out, login checks - Wallet: wallet state check (
CheckWalletAsync), wallet setup (SetupWalletAsync), address lookup, wallet selection (SelectWalletAsync) - Signing and transactions: sign message, sign typed data (on-chain vs off-chain), sign transaction, send transaction, wait for receipt
- RPC and chain access:
WalletRpcAsync,GetBalanceAsync,GetNonceAsync, chain-specific read operations - UI and confirmation:
EnableSignConfirmation,ApplyTheme, theme tokens, modal types (SignConfirmationModal,WalletFoundModal,PinInputModal) - Locale:
SetLocale,GetLocale
If a request spans multiple categories, handle setup and authentication prerequisites before wallet, signing, transaction, or RPC work.
Preconditions
Confirm the required setup before implementing a feature.
- SDK setup requires a real
ProjectIdandAppNameprovided by the user or already present in project configuration. - The deep link callback scheme is
crossy-{ProjectId}— derived automatically fromProjectId. - Android requires an intent filter in
AndroidManifest.xmlwithandroid:scheme="crossy-{ProjectId}". - iOS URL scheme registration is handled automatically by the SDK's
iOSBuildPostProcessor. - Windows requires running the generated
register_deeplink.regafter build. - Call
InitializeAsync()on app start to attempt session restore. - Call
EnableSignConfirmation(uiDocument.rootVisualElement)before any sign/send operations to enable the confirmation modal UI. - Wallet and RPC work require a valid login state and the correct CAIP-2 chain ID (
eip155:<number>). - After login, wallet-dependent flows may still require wallet setup. Call
CheckWalletAsync()to determine wallet state, then callSetupWalletAsync()if no wallet exists or migration is required. - Use
SetupWalletAsyncas the primary wallet setup method.CreateWalletAsyncis obsolete. WalletUnsignedTransaction.EvmEip155requires chainId via its constructor:new WalletUnsignedTransaction.EvmEip155("eip155:612044") { From = ..., To = ... }.- When using
WalletUnsignedTransactionoverloads ofSignTransactionAsync,SendTransactionAsync, orSendTransactionWithWaitForReceiptAsync, do not pass a separatechainIdparameter — it is derived from the transaction object.
Guardrails
- Do not assume authentication is complete unless
InitializeAsync()and session flow are wired correctly. - Do not use wallet or RPC features as the default path before confirming login state.
- Do not use
WalletRpcAsyncfor transaction signing or sending flows — it is read-only. - Do not pass a
chainIdargument toSignTransactionAsync,SendTransactionAsync, orSendTransactionWithWaitForReceiptAsyncwhen using theWalletUnsignedTransactionoverload. - Do not use the obsolete
CreateWalletAsync— useSetupWalletAsyncinstead. - Do not add new wrappers or architectural layers when the feature can fit existing MonoBehaviours.
- Do not guess unclear SDK behavior when the latest documentation or MCP resources should be checked first.
- Do not generate fallback values such as
unity-sample,my-game, or placeholder IDs forProjectId. - If
ProjectIdis missing, ask the user for it before writing SDK setup or manifest configuration.
Implementation Workflow
- Identify the feature category and the affected Unity files.
- Inspect the existing project structure before making changes.
- Confirm the required setup before adding feature code.
- Apply the smallest code change that fits the existing architecture and style.
- Use the correct SDK APIs, CAIP-2 chain IDs, and parameter requirements.
- Review the affected files for integration gaps before finalizing.
Validation Checklist
Before finalizing CROSSx Unity SDK changes, verify the following:
- The change matches the requested feature scope without unnecessary refactoring.
SDKConfigincludes a realProjectIdandAppName.- Android manifest has the correct deep link scheme (
crossy-{ProjectId}) when auth flows are used. InitializeAsync()is called on app start.EnableSignConfirmation(uiDocument.rootVisualElement)is called before sign/send operations.- Authentication, wallet, and RPC flows satisfy login and session requirements.
- After login, confirm wallet state with
CheckWalletAsync()for wallet-dependent flows; set up withSetupWalletAsync()if needed. WalletUnsignedTransaction.EvmEip155is constructed with chainId via constructor, not as a property.WalletUnsignedTransactionoverloads of sign/send methods do not include achainIdparameter.WalletRpcAsyncis only used for read-only call scenarios.- When catching errors, handle
GatewayException(checkErrorCodefor PIN lock, wallet-not-found, etc.) andSessionExpiredException(requires sign-out and re-login) separately from other errors.
Updated about 20 hours ago