sign_raw_transaction
Sign raw VeChain blockchain transactions using cryptographic keys to authorize and validate network operations before execution.
Instructions
Decode and sign a raw transaction.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rawTransaction | Yes |
Implementation Reference
- src/tools.ts:576-599 (handler)The handler function for 'sign_raw_transaction' tool. It retrieves the agent's secret key from environment, decodes the raw transaction hex, signs it with the secret key, encodes the signed transaction back to hex, and returns it as a text response.callback: async ({ rawTransaction }: { rawTransaction: string }) => { 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 decodedTxBytes = Hex.of(rawTransaction).bytes const decodedTx = Transaction.decode(decodedTxBytes, true); const signedTx = decodedTx.sign(secretKeyBytes) const signedTxBytes = signedTx.encoded const signedTxHex = Hex.of(signedTxBytes).toString() return { content: [{ type: "text", text: JSON.stringify(signedTxHex, null, 2) }] }; }
- src/tools.ts:573-575 (schema)Input schema for the 'sign_raw_transaction' tool, requiring a 'rawTransaction' string.inputSchema: { rawTransaction: z.string(), },
- src/tools.ts:569-600 (registration)Registration of the 'sign_raw_transaction' tool in the tools array, including name, title, description, schema, and inline handler callback.{ name: "sign_raw_transaction", title: "Sign raw transaction", description: "Decode and sign a raw transaction.", inputSchema: { rawTransaction: z.string(), }, callback: async ({ rawTransaction }: { rawTransaction: string }) => { 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 decodedTxBytes = Hex.of(rawTransaction).bytes const decodedTx = Transaction.decode(decodedTxBytes, true); const signedTx = decodedTx.sign(secretKeyBytes) const signedTxBytes = signedTx.encoded const signedTxHex = Hex.of(signedTxBytes).toString() return { content: [{ type: "text", text: JSON.stringify(signedTxHex, null, 2) }] }; } }