Skip to main content
Glama

zetrix_contract_get_structure_guide

Learn to structure Zetrix smart contracts using ES5 patterns, classes, and inheritance for blockchain development.

Instructions

Get guide on how to structure Zetrix smart contracts with ES5 patterns, classes, and inheritance

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core implementation of the tool: the getStructureGuide() method in ZetrixContractDocs class that returns a comprehensive markdown guide on ES5 class patterns, inheritance, and storage for Zetrix smart contracts.
    getStructureGuide(): string { return `# Zetrix Smart Contract Structure Guide ## ES5 Class Pattern \`\`\`javascript const MyContract = function() { const self = this; // Private variables (local scope) const _privateVar = 'private'; // Public variables self.publicVar = 'public'; // Protected namespace self.p = {}; // Private method const _privateMethod = function() { return _privateVar; }; // Public method self.publicMethod = function() { return self.publicVar; }; // Protected method self.p.protectedMethod = function() { return _privateMethod(); }; // Constructor/Initialize self.init = function(param1, param2) { self.publicVar = param1; }; }; // Entry points function init(input) { const contract = new MyContract(); contract.init(input); } function main(input) { // Handle transactions } function query(input) { // Handle read-only queries } \`\`\` ## Inheritance Pattern \`\`\`javascript const ParentContract = function() { const self = this; self.p = {}; self.p.parentMethod = function() { return 'parent'; }; }; const ChildContract = function() { const self = this; // Call parent constructor ParentContract.call(self); // Save reference to parent method const _parentMethod = self.p.parentMethod; // Override parent method self.p.parentMethod = function() { const result = _parentMethod.call(self); return result + ' extended'; }; }; \`\`\` ## Storage Pattern \`\`\`javascript const TokenContract = function() { const self = this; const TOTAL_SUPPLY = 'totalSupply'; const BALANCE_PREFIX = 'balance_'; self.getBalance = function(address) { const key = BALANCE_PREFIX + address; return Chain.load(key) || '0'; }; self.setBalance = function(address, amount) { const key = BALANCE_PREFIX + address; Chain.store(key, amount); }; }; \`\`\` See SMART_CONTRACT_DEVELOPMENT.md for complete guide.`; }
  • The dispatch handler in the main switch statement that calls the getStructureGuide method and formats the response.
    case "zetrix_contract_get_structure_guide": { const docs = zetrixContractDocs.getStructureGuide(); return { content: [ { type: "text", text: docs, }, ], }; }
  • src/index.ts:678-684 (registration)
    Tool registration in the tools array, including name, description, and empty input schema (no parameters required).
    name: "zetrix_contract_get_structure_guide", description: "Get guide on how to structure Zetrix smart contracts with ES5 patterns, classes, and inheritance", inputSchema: { type: "object", properties: {}, }, },
  • Input schema definition: empty object (no input parameters needed).
    inputSchema: { type: "object", properties: {}, },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Zetrix-Chain/zetrix-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server