issueSessionKey
issueSessionKey(
params):Promise<KawasekitSessionEnvelope>
Defined in: src/session/issue.ts:102
Issues a fresh session key for an agent smart account.
Notes:
- The session-key private key is not embedded in the returned envelope. The agent must receive the private key out-of-band; the envelope alone is not enough to spend.
- The smart account is not deployed by this call. It will be deployed
on first userOp from
restoreSessionAccount.
Parameters
params
Returns
Promise<KawasekitSessionEnvelope>
Example
import { parseUnits } from "viem";import { privateKeyToAccount } from "viem/accounts";import { createJpycDailyLimitPolicies, getJpycAddress, issueSessionKey, JPYC_DECIMALS, polygonAmoy, serializeSessionEnvelope,} from "kawasekit";
const owner = privateKeyToAccount(process.env.OWNER_PRIVATE_KEY as `0x${string}`);const sessionKey = privateKeyToAccount(process.env.SESSION_KEY_PRIVATE_KEY as `0x${string}`);
const envelope = await issueSessionKey({ publicClient, ownerSigner: owner, sessionKeySigner: sessionKey, policies: createJpycDailyLimitPolicies({ jpycAddress: getJpycAddress(polygonAmoy.id), maxPerTransfer: parseUnits("100", JPYC_DECIMALS), maxTransfersPerDay: 10, }), policySummary: { jpycAddress: getJpycAddress(polygonAmoy.id), maxPerTransfer: parseUnits("100", JPYC_DECIMALS), maxTransfersPerDay: 10, },});
fs.writeFileSync("agent.session", serializeSessionEnvelope(envelope));