MCPcopy
hub / github.com/codeaashu/claude-code / handleSetup

Function handleSetup

src/commands/x402/x402.ts:68–96  ·  view source on GitHub ↗
(args: string)

Source from the content-addressed store, hash-verified

66}
67
68function handleSetup(args: string): string {
69 const parts = args.trim().split(/\s+/)
70 const keyArg = parts[1]
71
72 if (keyArg) {
73 // Import existing key
74 try {
75 const address = saveX402PrivateKey(keyArg)
76 saveX402Config({ enabled: true })
77 return `Wallet imported and enabled.\nAddress: ${address}\n\nFund this address with USDC on ${getX402Config().network} to enable payments.`
78 } catch (err) {
79 return `Error importing key: ${err instanceof Error ? err.message : String(err)}`
80 }
81 }
82
83 // Generate new key
84 const privateKey = generateX402PrivateKey()
85 const address = saveX402PrivateKey(privateKey)
86 saveX402Config({ enabled: true })
87
88 return `New wallet generated and enabled.
89Address: ${address}
90Network: ${getX402Config().network}
91
92IMPORTANT: Fund this address with USDC to enable payments.
93Your private key is stored in ~/.claude/config.json
94
95To use on testnet first: /x402 network base-sepolia`
96}
97
98function handleStatus(): string {
99 const config = getX402Config()

Callers 1

callFunction · 0.85

Calls 4

saveX402PrivateKeyFunction · 0.85
saveX402ConfigFunction · 0.85
getX402ConfigFunction · 0.85
generateX402PrivateKeyFunction · 0.85

Tested by

no test coverage detected