sign_certificate
Create and sign canonical certificates for identification, attestation, or verification purposes on the VeChain blockchain. Specify domain, payload, and expiration to generate verifiable certificates.
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:519-567 (registration)Registration of the 'sign_certificate' tool in the vechainTools array. Includes name, description, input schema, and inline callback handler.{ name: "sign_certificate", title: "Sign certificate", description: "Create and sign a canonical certificate. Includes purpose, payload, domain, timestamp, nonce, and expiresAt.", 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(), }, 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:529-566 (handler)The handler callback that implements the tool logic: retrieves agent secret key from environment, derives public key and address, creates a Certificate object, signs it, and returns the signature as JSON.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: purpose (enum), payload (any), domain (string), timestamp (optional number).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(), },