Skip to main content
Glama
Zetrix-Chain

Zetrix MCP Server

Official
by Zetrix-Chain

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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.`;
      }
  • 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,
          },
        ],
      };
    }

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