zetrix_contract_get_structure_guide
Learn how 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 main handler function that returns the detailed guide on Zetrix smart contract structure using ES5 patterns, inheritance, and storage examples.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:678-684 (schema)Tool schema definition 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:1407-1417 (registration)Tool registration in the MCP server request handler switch statement, which calls the implementation and formats the response.case "zetrix_contract_get_structure_guide": { const docs = zetrixContractDocs.getStructureGuide(); return { content: [ { type: "text", text: docs, }, ], }; }