Skip to main content

Building Custom Blocks

Extend Zzyra’s planned automation capabilities with your own custom blocks. Create powerful integrations, specialized workflows, and unique automation logic tailored to your specific needs.
Current Status: Basic AI-assisted block creation available Planned: Advanced SDK, marketplace, and developer rewards program

Block Architecture

User Interface

Form FieldsConfigurationValidation

Block Logic

Input ProcessingBusiness LogicOutput Generation

Integration Layer

API CallsWeb3 InteractionsData Processing

Example Custom Block Development

Example: Creating a “Price Alert” block that monitors cryptocurrency prices and sends notifications when thresholds are met.

Block Definition

// Planned SDK structure (in development)
import { Block, BlockConfig, BlockInput, BlockOutput } from '@zzyra/blocks';

interface PriceAlertConfig {
symbol: string;
threshold: number;
condition: 'above' | 'below';
notificationChannel: 'email' | 'discord' | 'slack';
}

// Planned decorator pattern (in development)
@Block({
name: 'Price Alert',
description: 'Monitor cryptocurrency prices and send alerts',
category: 'Trading',
version: '1.0.0'
})
export class PriceAlertBlock {

@BlockConfig()
config: PriceAlertConfig;

async execute(): Promise<void> {
const { symbol, threshold, condition } = this.config;
const { currentPrice } = this.input;

    let alertTriggered = false;
    let message = '';

    if (condition === 'above' && currentPrice > threshold) {
      alertTriggered = true;
      message = `🚀 ${symbol} price is above $${threshold}! Current: $${currentPrice}`;
    }

    this.output = {
      alertTriggered,
      message,
      timestamp: new Date().toISOString()
    };

}
}

Block Preview

Development Workflow

1

Define Requirements

Identify the automation need and define inputs, outputs, and configuration
2

Create Block Structure

Set up the block class with proper decorators and interfaces
3

Implement Logic

Write the core business logic and integration code
4

Test & Validate

Test the block with various inputs and edge cases
5

Deploy & Share

Deploy to Zzyra marketplace and share with the community

Advanced Patterns

Web3 Integration Block

@Block({
  name: 'DeFi Yield Automation',
  description: 'Automate DeFi yield farming operations',
  category: 'DeFi',
  version: '2.0.0'
})
export class DeFiYieldBlock {

  async execute(): Promise<void> {
    const { protocol, action, amount } = this.config;

    // Initialize protocol-specific contract
    const contract = await this.getProtocolContract(protocol);

    let transaction;
    switch (action) {
      case 'deposit':
        transaction = await this.deposit(amount);
        break;
      case 'withdraw':
        transaction = await this.withdraw(amount);
        break;
      case 'harvest':
        transaction = await this.harvest();
        break;
    }

    const receipt = await transaction.wait();

    this.output = {
      transactionHash: receipt.transactionHash,
      success: true,
      gasUsed: receipt.gasUsed.toString()
    };
  }
}
@Block({
  name: 'AI Trading Advisor',
  description: 'AI-powered trading recommendations',
  category: 'AI Trading',
  version: '1.0.0'
})
export class AITradingBlock {
  
  async execute(): Promise<void> {
    const { model, strategy } = this.config;
    const { marketData, portfolio } = this.input;
    
    // Prepare context for AI analysis
    const context = this.prepareAnalysisContext(marketData, portfolio);
    
    // Generate AI recommendations
    const response = await this.openai.chat.completions.create({
      model: model === 'gpt-4' ? 'gpt-4' : 'gpt-3.5-turbo',
      messages: [
        {
          role: 'system',
          content: 'You are an expert cryptocurrency trading advisor.'
        },
        {
          role: 'user',
          content: `Analyze this market data: ${JSON.stringify(context)}`
        }
      ]
    });
    
    const aiRecommendation = JSON.parse(response.choices[0].message.content);
    
    this.output = {
      recommendations: this.validateRecommendations(aiRecommendation),
      confidence: aiRecommendation.confidence,
      reasoning: aiRecommendation.reasoning
    };
  }
}

Testing Framework

describe('PriceAlertBlock', () => {
  let block: PriceAlertBlock;
  
  beforeEach(() => {
    block = new PriceAlertBlock();
    block.config = {
      symbol: 'ETH',
      threshold: 3000,
      condition: 'above',
      notificationChannel: 'email'
    };
  });
  
  it('should trigger alert when price is above threshold', async () => {
    block.input = {
      currentPrice: 3200,
      marketData: {}
    };
    
    await block.execute();
    
    expect(block.output.alertTriggered).toBe(true);
    expect(block.output.message).toContain('🚀 ETH price is above $3000');
  });
});

Block Marketplace

Published Blocks

150+

Active Users

2,500+

Developer Rewards

$45K

Publishing Steps

1

Prepare Your Block

Ensure your block is well-tested and documented
2

Create Listing

Add description, pricing, and usage examples
3

Submit for Review

Our team reviews for quality and security
4

Go Live

Your block is available to the community

Getting Started

Custom blocks are the foundation of Zzyra’s extensibility. By building and sharing blocks, you contribute to the ecosystem and help others automate their workflows more effectively.