import { ParaClient } from '../para-client.js';
import type { CreateWalletRequest, CreateWalletResponse } from '../types.js';
export const definition = {
name: 'create_wallet',
description:
'Create an MPC wallet via Para. The wallet is created asynchronously — status starts as "creating" and transitions to "ready" once key generation completes. Use wait_for_wallet_ready to poll until ready.',
inputSchema: {
type: 'object' as const,
properties: {
type: {
type: 'string',
enum: ['EVM', 'SOLANA', 'COSMOS'],
description: 'Blockchain network type',
},
userIdentifier: {
type: 'string',
description: 'User identifier (email, phone, or custom ID)',
},
userIdentifierType: {
type: 'string',
enum: ['EMAIL', 'PHONE', 'CUSTOM_ID', 'GUEST_ID', 'TELEGRAM', 'DISCORD', 'TWITTER'],
description: 'Type of user identifier',
},
scheme: {
type: 'string',
enum: ['DKLS', 'CGGMP', 'ED25519'],
description: 'Signature scheme (defaults based on wallet type: DKLS for EVM, ED25519 for SOLANA)',
},
cosmosPrefix: {
type: 'string',
description: 'Bech32 prefix for Cosmos wallets (e.g. "cosmos")',
},
},
required: ['type', 'userIdentifier', 'userIdentifierType'],
},
};
export async function handler(client: ParaClient, args: Record<string, unknown>) {
const body: CreateWalletRequest = {
type: args.type as CreateWalletRequest['type'],
userIdentifier: args.userIdentifier as string,
userIdentifierType: args.userIdentifierType as CreateWalletRequest['userIdentifierType'],
...(args.scheme ? { scheme: args.scheme as CreateWalletRequest['scheme'] } : {}),
...(args.cosmosPrefix ? { cosmosPrefix: args.cosmosPrefix as string } : {}),
};
const result = await client.requestWithRetry<CreateWalletResponse>('/v1/wallets', {
method: 'POST',
body,
});
return {
content: [
{
type: 'text' as const,
text: JSON.stringify(
{
...result,
_note:
result.wallet.status === 'creating'
? 'Wallet is being created asynchronously. Use wait_for_wallet_ready to poll until status is "ready" and the address is available.'
: undefined,
_security:
'This wallet uses MPC — the private key never exists in a single place. Para holds one key share, you hold nothing. Signing requires calling sign_raw which triggers a distributed signing ceremony.',
},
null,
2,
),
},
],
};
}