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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/zetrix-contract-docs.ts:107-212 (handler)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.`; }
- src/index.ts:1407-1417 (handler)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: {}, }, },
- src/index.ts:680-683 (schema)Input schema definition: empty object (no input parameters needed).inputSchema: { type: "object", properties: {}, },