sign_certificate
Create and sign canonical certificates for identification, attestation, or verification purposes with domain-specific validity, payload content, and timestamping on the VeChain blockchain.
Instructions
Create and sign a canonical certificate. Includes purpose, payload, domain, timestamp, nonce, and expiresAt.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| purpose | No | identification | |
| payload | No | Content to be attested (string or JSON) | |
| domain | Yes | Scope or domain where it is valid | |
| timestamp | No |
Implementation Reference
- src/tools.ts:529-566 (handler)The main handler function for the 'sign_certificate' tool. It derives the public key address from the AGENT_SECRET_KEY environment variable, creates a Certificate using the provided parameters, signs it, and returns the signature as JSON text.callback: async ({ purpose, payload, domain, timestamp = Math.floor(Date.now() / 1000), }: { purpose: "identification" | "attestation" | "verification", payload: any, domain: string, timestamp?: number }) => { const secretKey = process.env.AGENT_SECRET_KEY if (!secretKey) { throw new Error("Missing AGENT_SECRET_KEY variable to use this tool.") } const secretKeyBytes = Address.of(secretKey).bytes const publicKey = Secp256k1.derivePublicKey(secretKeyBytes); const publicKeyAddress = Address.ofPublicKey(publicKey).toString(); const certificate = Certificate.of({ purpose, payload, timestamp, domain, signer: publicKeyAddress }) const signature = certificate.sign(secretKeyBytes); return { content: [{ type: "text", text: JSON.stringify(signature, null, 2) }] }; }
- src/tools.ts:523-528 (schema)Zod input schema defining the parameters for the sign_certificate tool: purpose (enum with default), payload (any), domain (required string), and optional timestamp (positive integer).inputSchema: { purpose: z.enum(["identification", "attestation", "verification"]).default("identification"), payload: z.any().describe("Content to be attested (string or JSON)"), domain: z.string().min(1).describe("Scope or domain where it is valid"), timestamp: z.number().int().positive().optional(), },
- src/server.ts:74-92 (registration)Registers the 'sign_certificate' tool (as part of vechainTools array) with the MCP server using server.registerTool, passing the tool's name, description, inputSchema, and a wrapper that invokes the tool's callback function.for (const t of vechainTools) { server.registerTool( t.name, { title: t.name, description: t.description, inputSchema: t.inputSchema }, async (args) => { const result = await t.callback(args); return { content: result.content.map(item => ({ ...item, type: "text" as const })) }; } ); }