Server-only method. Requires API secret key.
Usage
const upgrade = await sdk.prepareWalletUpgrade(
{ walletAddress: "0x..." },
bearerToken,
);
Parameters
| Parameter | Type | Required | Description |
|---|
walletAddress | string | Yes | Wallet address to upgrade |
targetClassHash | string | No | Target class hash (defaults to latest CHIPI) |
bearerToken | string | No | JWT token. Falls back to apiSecretKey if not provided |
Return Value
Returns a Promise<PrepareWalletUpgradeResponse>:
| Field | Type | Description |
|---|
typedData | TypedData | SNIP-12 typed data to sign |
currentClassHash | string | Current class hash of the wallet |
targetClassHash | string | Target class hash for upgrade |
currentWalletType | WalletType | Current wallet type |
targetWalletType | WalletType | Target wallet type after upgrade |
Example
// Prepare upgrade from READY to CHIPI
const upgrade = await sdk.prepareWalletUpgrade(
{ walletAddress: "0x04abc...def" },
bearerToken,
);
console.log(upgrade.currentWalletType); // "READY"
console.log(upgrade.targetWalletType); // "CHIPI"
// Sign the typed data (using starknet.js Account)
const signature = await account.signMessage(upgrade.typedData);
// Execute the upgrade
const result = await sdk.executeWalletUpgrade(
{
walletAddress: "0x04abc...def",
typedData: upgrade.typedData,
signature: [signature.r.toString(), signature.s.toString()],
},
bearerToken,
);