Skip to main content

Bringing an existing dApp

You can make an existing web3 app run inside CrackPay. Its screens and logic carry over; what changes is how it reaches the wallet, the chain it uses, and a few assumptions about accounts and gas.

What changes​

A typical dAppInside CrackPay
WalletA wallet picker and a "Connect wallet" buttonConnected on load through @crackpay/miniapp-sdk
Detectionwindow.ethereum at page loadawait getCrackPayProvider()
ChainWhatever it targetsArc mainnet 5042 (or Arc Testnet 5042002), read from the provider
GasPaid by the user, estimated by the appSponsored by CrackPay, nothing to set
AccountA private-key walletA passkey smart account
StablecoinsVariesUSDC and EURC on Arc
SigningMessages and typed dataNot available
ContainerA browser tabA frame inside the CrackPay page

Steps​

  1. Find the wallet layer. Search for window.ethereum, connect buttons, wallet pickers, chain switching, gas estimation, signMessage and signTypedData.
  2. Install the SDK: npm install @crackpay/miniapp-sdk.
  3. Replace provider access with connectCrackPay() or useCrackPay(), and move startup code behind the promise. See Wallet connection.
  4. Remove the connect button and the wallet picker when running in CrackPay.
  5. Switch the chain to the Arc network CrackPay reports (arc or arcTestnet) and remove chain switching.
  6. Remove gas handling: fee estimates, gas fields and any gas reserve.
  7. Check token amounts. Arc's USDC is 6 decimals as a token and 18 as a native value. Replace direct token transfers with a call to your own contract. See Arc network.
  8. Remove signatures. Identify users by account address; replace permits and signed orders with on-chain calls.
  9. Deploy your contracts on Arc and check they accept smart-account callers. See Interacting with smart contracts.
  10. Allow framing by CrackPay; expect partitioned storage. See Deployment.
  11. Test in Developer mode and submit.

Running inside and outside CrackPay​

Pick the wallet once at startup and keep the rest of the app unaware of it:

import { connectCrackPay } from "@crackpay/miniapp-sdk/viem";

export async function connectWallet() {
// Inside CrackPay: connected at once, no prompt.
const crackpay = await connectCrackPay();
if (crackpay) return { wallet: "crackpay" as const, ...crackpay };

// Anywhere else: your usual wallet flow.
return connectWithYourUsualWalletFlow();
}

Outside a frame, connectCrackPay() resolves to null immediately, so the normal flow is not delayed. Keep per-environment values (chain, token addresses, contracts) in one table keyed by wallet, and branch nowhere else.