sendCyberlink
Create connections between IPFS content identifiers on the Cyber network to establish semantic relationships in the decentralized knowledge graph.
Instructions
Create a cyberlink between two IPFS CIDs on the Cyber network
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| from | Yes | Source CID or text (will be converted to CID if not a valid CID) | |
| to | Yes | Target CID or text (will be converted to CID if not a valid CID) | |
| fee | No | Transaction fee (optional) |
Implementation Reference
- src/index.ts:152-209 (handler)The core implementation of the sendCyberlink tool. Handles input validation, CID conversion, wallet signing, and transaction submission via the CyberClient's cyberlink method.private async handleSendCyberlink(args: { from: string; to: string; fee?: any; }) { try { // Check if wallet is initialized if (!this.wallet.isInitialized()) { return { content: [ { type: 'text', text: 'Error: No mnemonic provided. The sendCyberlink tool requires a wallet to sign transactions. Please provide CYBER_MNEMONIC in your environment variables.', }, ], isError: true, }; } // Convert to CIDs if necessary const fromCid = isValidCID(args.from) ? args.from : await getIpfsHash(args.from); const toCid = isValidCID(args.to) ? args.to : await getIpfsHash(args.to); const signingClient = this.wallet.getSigningClient(); const address = this.wallet.getAddress(); const fee = args.fee || { amount: [{ denom: BASE_DENOM, amount: '0' }], gas: '200000', }; const result = await signingClient.cyberlink( address, fromCid, toCid, fee ); return { content: [ { type: 'text', text: `Cyberlink created successfully!\nTransaction Hash: ${Array.isArray(result) ? 'Multiple transactions' : (result as any).transactionHash || 'Unknown'}\nFrom: ${fromCid}\nTo: ${toCid}`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error creating cyberlink: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }
- src/index.ts:53-87 (schema)Input schema for the sendCyberlink tool, specifying required 'from' and 'to' CIDs/texts and optional fee structure.inputSchema: { type: 'object', properties: { from: { type: 'string', description: 'Source CID or text (will be converted to CID if not a valid CID)', }, to: { type: 'string', description: 'Target CID or text (will be converted to CID if not a valid CID)', }, fee: { type: 'object', description: 'Transaction fee (optional)', properties: { amount: { type: 'array', items: { type: 'object', properties: { denom: { type: 'string' }, amount: { type: 'string' }, }, }, }, gas: { type: 'string' }, }, default: { amount: [{ denom: BASE_DENOM, amount: '0' }], gas: '200000', }, }, }, required: ['from', 'to'], },
- src/index.ts:50-88 (registration)Registration of the sendCyberlink tool in the listTools handler, providing name, description, and input schema.{ name: 'sendCyberlink', description: 'Create a cyberlink between two IPFS CIDs on the Cyber network', inputSchema: { type: 'object', properties: { from: { type: 'string', description: 'Source CID or text (will be converted to CID if not a valid CID)', }, to: { type: 'string', description: 'Target CID or text (will be converted to CID if not a valid CID)', }, fee: { type: 'object', description: 'Transaction fee (optional)', properties: { amount: { type: 'array', items: { type: 'object', properties: { denom: { type: 'string' }, amount: { type: 'string' }, }, }, }, gas: { type: 'string' }, }, default: { amount: [{ denom: BASE_DENOM, amount: '0' }], gas: '200000', }, }, }, required: ['from', 'to'], }, },
- src/index.ts:140-141 (registration)Dispatch registration in the CallToolRequestSchema handler, routing 'sendCyberlink' calls to the handler function.case 'sendCyberlink': return await this.handleSendCyberlink(args as any);
- src/config.ts:7-7 (helper)Configuration interface noting that mnemonic is required specifically for the sendCyberlink tool.mnemonic?: string; // Optional - only needed for sendCyberlink