Skip to main content

User profile

Every CrackPay user has an account address and a handle, like @sam. Your Mini App gets both the moment it connects, with no prompt.

With viem​

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

const crackpay = await connectCrackPay();
if (crackpay) {
greet(crackpay.handle ? `Hi @${crackpay.handle}` : "Hi there");
}

With React​

const crackpay = useCrackPay();
if (crackpay.status === "connected") {
return <h1>{crackpay.handle ? `Hi @${crackpay.handle}` : "Welcome"}</h1>;
}

With the provider​

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

const { account, handle } = await getCrackPayUser(provider);

Or the raw method: provider.request({ method: "crackpay_getProfile" }).

Using it well​

  • Greet users by handle, and show who paid ("Paid by @sam").
  • Identify users by account. Store the account, not the handle.
  • Fall back to a short address when handle is null.
  • The handle is public: anyone can look it up from the account on-chain, so showing it reveals nothing new.

Requires @crackpay/miniapp-sdk 0.2.0 or later.