Wallet
Unity Wallet
This guide covers wallet creation/address APIs, signing/sending, and receipt polling.
Prerequisites
- User should be authenticated (
sdk.SignInAsync()completed). - EVM chain routing requires
chainId(recommended format:eip155:<number>). - Confirmation UI should be enabled via
sdk.EnableSignConfirmation(uiRoot).
Address & wallet APIs
// Check wallet status
var check = await sdk.CheckWalletAsync();
// Set up wallet (create / migrate / verify) — PIN and wallet found modals are handled internally by the SDK
if (check.NotFound || check.MigrationRequired)
{
var setup = await sdk.SetupWalletAsync();
Debug.Log($"Wallet ready: {setup.IsReady}, address: {setup.Address}");
}
// Or use CreateWalletAsync with migration control
var created = await sdk.CreateWalletAsync(migrateAutomatically: true);
// Get addresses
var primary = await sdk.GetAddressAsync();
var byIndex = await sdk.GetAddressAsync(index: 0);
var all = await sdk.GetAddressesAsync();
// Let the user select a wallet address
var selection = await sdk.SelectWalletAsync();
if (selection != null)
Debug.Log($"Selected: {selection.Address} (index {selection.Index})");Wallet password and biometrics
The SDK may show password entry and confirmation UI before signing and sending. After verification once, the password is reused for later operations.
bool can = sdk.CanUseBiometric();
bool enabled = sdk.IsBiometricEnabled();
await sdk.SetBiometricEnabledAsync(true);Sign message / typed data
These APIs open SDK confirmation modal (UI Toolkit).
string chainId = "eip155:612044";
var signMessageResp = await sdk.SignMessageAsync(
message: "Hello CROSSx",
chainId: chainId
);
var signTypedResp = await sdk.SignTypedDataAsync(
typedData: new Eip712TypedData
{
Types = new Dictionary<string, List<Eip712Field>>(),
PrimaryType = "Mail",
Domain = JObject.Parse("{}"),
Message = JObject.Parse("{}")
},
chainId: chainId
);Sign transaction
Preferred SDK-level model:
var walletTx = new WalletUnsignedTransaction.EvmEip155("eip155:612044")
{
From = "0xYourAddress",
To = "0xRecipient",
Value = "0xde0b6b3a7640000",
Data = "0x"
};
var signTxResp = await sdk.SignTransactionAsync(walletTx);If you need raw gateway payload control, UnsignedTx overloads are also available.
var tx = new UnsignedTx
{
ChainId = "eip155:612044",
From = "0xYourAddress",
To = "0xRecipient",
Value = "0xde0b6b3a7640000",
Data = "0x"
};
var signTxResp = await sdk.SignTransactionAsync(
unsignedTx: tx,
chainId: tx.ChainId
);Send transaction
var sendResp = await sdk.SendTransactionAsync(walletTx);
var txHash = sendResp.TxHash;Send + wait for receipt in one call
TransactionReceipt receipt = await sdk.SendTransactionWithWaitForReceiptAsync(
walletTx: walletTx,
timeoutMs: 30000,
pollIntervalMs: 1000
);
Debug.Log($"TxHash: {receipt.TransactionHash}, Status: {receipt.Status}");Manual receipt polling
TransactionReceipt receipt = await sdk.WaitForTxAndGetReceiptAsync(
txHash: "0x...",
chainId: "eip155:612044",
timeoutMs: 30000,
pollIntervalMs: 1000
);RPC helpers
var rpcResp = await sdk.WalletRpcAsync(
request: new JsonRpcRequest
{
Id = "1",
Jsonrpc = "2.0",
Method = "eth_call",
Params = new JArray { /* ... */ }
},
chainId: "eip155:612044"
);
var balanceHex = await sdk.GetBalanceAsync(
address: "0xYourAddress",
chainId: "eip155:612044"
);
var nonceHex = await sdk.GetNonceAsync(
address: "0xYourAddress",
chainId: "eip155:612044",
blockTag: "pending"
);
WalletRpcAsyncis intended for contract read/call only (e.g.eth_call). Sending/signing transaction methods are not supported through this RPC API.
Confirmation UI
The SDK provides built-in UI Toolkit modals for transaction confirmation. Enable them after initialization:
sdk.EnableSignConfirmation(
uiRoot: uiDocument.rootVisualElement,
theme: ThemeMode.Dark,
appName: "My Game"
);Modal types managed by the SDK:
- SignConfirmationModal — sign/send confirmation (PersonalSign, TypedData, Transaction)
- WalletFoundModal — existing wallet recovery prompt (managed internally)
- PinInputModal — password entry (managed internally)
- SessionExpiredModal — session expiry handling with sign-in again / sign-out options
- WalletCompleteModal — wallet creation success notification
Updated about 22 hours ago