Transform your ideas into powerful, monetizable elements within the DEFAI workspace ecosystem. Our Elements SDK empowers developers to create sophisticated AI-powered components that users can seamlessly integrate into their workspaces while generating sustainable revenue streams.
- π Rapid Development - Pre-built templates and scaffolding get you started in minutes
- π° Built-in Monetization - Sell elements as Semi-Fungible Tokens (SFTs) on our marketplace
- π Secure Sandbox - Run in isolated environments with granular permission controls
- π€ AI-First - Native integration with AI agents and blockchain services
- π¨ React Ecosystem - Build with familiar tools and modern frameworks
- π Analytics & Insights - Track usage, performance, and revenue in real-time
We're committed to fostering innovation in the DEFAI ecosystem by allocating 1% of the total DEFAI token supply (1 billion tokens) specifically for element builders and developers.
π₯ Bronze Tier (100 - 1,000 DEFAI)
- New developers building their first elements
- Educational projects and proof-of-concepts
- Community tools and utilities
π₯ Silver Tier (1,000 - 10,000 DEFAI)
- Production-ready elements with active users
- Open-source contributions to the SDK
- Educational content and tutorials
π₯ Gold Tier (10,000 - 100,000 DEFAI)
- High-impact elements with significant user adoption
- Major SDK features and infrastructure improvements
- Partnership integrations and enterprise solutions
π Platinum Tier (100,000+ DEFAI)
- Ecosystem-defining innovations
- Major platform integrations
- Revolutionary AI/DeFi applications
- Build Your Element - Use our SDK and sample templates
- Deploy & Validate - Publish to our testnet marketplace
- Submit Proposal - Include usage metrics and impact assessment
- Community Review - Get feedback from DEFAI community
- Grant Approval - Receive tokens based on tier qualification
Apply at: grants.defai.com
"The DEFAI grant program allowed us to focus on innovation instead of funding. We built a trading bot element that now has 10,000+ active users!" β Maya Chen, DeFi Builder
"Starting with a Bronze grant, we've grown to Gold tier. The community support and token incentives made all the difference." β Alex Rodriguez, AI Developer
Get your first element running in under 5 minutes:
Option A: Homebrew (Recommended for macOS)
brew install defaiOption B: npm
npm install -g @defai/element-cliExperience the full power of the SDK with our comprehensive trading workspace:
cd sample-workspace-template
npm install
npm run devThis opens a fully functional AI trading workspace at http://localhost:3000 featuring:
- π Real-time portfolio tracking
- π€ AI-powered market analysis
- π± Complete trading interface
- π Inter-element messaging
- βοΈ All SDK APIs demonstrated
# Create a new element project
defai-element create my-trading-bot --template react
# Navigate to project
cd my-trading-bot
# Install dependencies
npm install
# Start development server with hot reload
defai-element dev# Build for production
npm run build
# Validate your element
npm run validate
# Publish to the marketplace
npm run publish --tier bronze --price 100- Node.js 16+ and npm/yarn
- Solana wallet with DEFAI tokens for publishing
- Basic knowledge of React/TypeScript
# Install DEFAI CLI globally
brew install defai
# OR
npm install -g @defai/element-cli
# Clone the SDK repository
git clone https://github.com/defaiza/element-sdk
cd element-sdk
# Install dependencies and build packages
npm install
npm run build
# Install core SDK packages for your projects
npm install @defai/element-sdk @defai/element-react @defai/element-types
# Verify installation
defai-element --versionOur comprehensive package ecosystem supports every aspect of element development:
# Core Development
npm install @defai/element-sdk # Core SDK and base classes
npm install @defai/element-react # React hooks and components
npm install @defai/element-types # TypeScript definitions
# Development Tools
npm install -g @defai/element-cli # CLI for scaffolding and publishing
npm install @defai/element-templates # Pre-built element templates
npm install @defai/element-testing # Testing utilities and mocks
# Advanced Features
npm install @defai/element-validator # Code validation and security checksDEFAI Elements are modular, AI-powered components that run in secure sandbox environments within user workspaces. They can integrate with blockchain services, AI agents, and external APIs while maintaining strict security boundaries.
import { DefaiElement } from '@defai/element-sdk';
export default class MyElement extends DefaiElement {
// Required metadata
readonly metadata = {
id: 'my-element',
name: 'My Awesome Element',
version: '1.0.0',
description: 'Does amazing things',
category: 'Trading'
};
// Define permissions needed
readonly permissions = {
storage: true,
wallet: true,
ai: true,
network: true
};
// Lifecycle hooks
async onMount(context) {
// Element initialization
this.api = context.api;
console.log('Element mounted!');
}
async onUnmount() {
// Cleanup
console.log('Element unmounting...');
}
// React render method
render() {
return <div>Hello DEFAI!</div>;
}
}- π¦ Wallet API - Balance queries, transaction signing, permission management
- π€ AI Services - Chat, analysis, content generation with various models
- πΎ Storage API - Persistent key-value storage with encryption
- π‘ Messaging API - Inter-element communication and event broadcasting
- π Market Data - Real-time price feeds and historical data
- π Notifications - User alerts and confirmation dialogs
Our sample workspace demonstrates enterprise-grade element development:
cd sample-workspace-template
npm install
npm run dev # Start development server
npm run build # Production build
npm run test # Run test suite
npm run validate # Validate elementπ Portfolio Management
- Real-time balance tracking
- P&L calculations
- Position management
- Trading history
π€ AI Integration
- Market sentiment analysis
- Trading signal generation
- Risk assessment
- Automated insights
π± Trading Interface
- Order execution (market/limit)
- Multi-asset support
- Risk controls
- Quick trade actions
π Real-time Features
- Live price updates
- Inter-element messaging
- Portfolio synchronization
- AI analysis broadcasting
sample-workspace-template/
βββ src/
β βββ index.tsx # Main element entry
β βββ components/ # React components
βββ public/
β βββ index.html # HTML template
βββ webpack.config.js # Build configuration
βββ package.json # Dependencies
βββ README.md # Template guide
-
Fork the Template
cp -r sample-workspace-template my-element cd my-element -
Modify the Core Component
// src/index.tsx export default class MyCustomElement extends DefaiElement { readonly metadata = { id: 'my-custom-element', name: 'My Custom Element', // ... your metadata }; }
-
Add Your Features
- Create new components in
src/components/ - Integrate with additional APIs
- Customize styling and layout
- Add tests for new functionality
- Create new components in
-
Deploy
npm run build npm run validate defai-element publish --tier bronze
// Subscribe to messages from other elements
this.api.messaging.subscribe('price-alerts', (alert) => {
if (alert.symbol === this.state.watchedSymbol) {
this.showNotification(alert.message);
}
});
// Broadcast data to other elements
this.api.messaging.broadcast('trade-executed', {
symbol: 'SOL-USD',
amount: 100,
price: 45.67,
timestamp: Date.now()
});// Market sentiment analysis
const sentiment = await this.api.ai.analyze('market-sentiment', {
symbols: ['SOL-USD', 'BTC-USD'],
timeframe: '1h',
includeNews: true
});
// Generate trading insights
const insights = await this.api.ai.generate(
'Analyze the SOL price movement and provide 3 key trading insights'
);
// Chat with AI assistant
const response = await this.api.ai.chat(
'What are the best DeFi opportunities this week?',
{ context: this.state.portfolio }
);// Check balances
const solBalance = await this.api.wallet.getBalance('SOL');
const usdcBalance = await this.api.wallet.getBalance('USDC');
// Request transaction permission
const permitted = await this.api.wallet.requestPermission('transaction');
if (permitted) {
// Execute trade
const txHash = await this.api.wallet.sendTransaction({
type: 'swap',
from: 'SOL',
to: 'USDC',
amount: 10
});
}// Save user preferences
await this.api.storage.set('user-preferences', {
theme: 'dark',
defaultSlippage: 0.5,
autoTrade: false
});
// Load portfolio data
const portfolio = await this.api.storage.get('user-portfolio');
// List all stored keys
const keys = await this.api.storage.list('trade-history-');# Run tests with coverage
npm run test -- --coverage
# Test specific element
cd my-element
npm run test
# Integration testing
npm run test:integration
# Performance testing
npm run test:performance# Validate element structure
defai-element validate
# Strict validation for marketplace
defai-element validate --strict
# Security audit
defai-element audit
# Performance analysis
defai-element analyze --bundle-sizeimport { mockElementAPI } from '@defai/element-testing';
describe('MyElement', () => {
beforeEach(() => {
mockElementAPI({
wallet: {
getBalance: jest.fn(() => Promise.resolve(1000)),
sendTransaction: jest.fn(() => Promise.resolve('mock-tx-hash'))
},
ai: {
analyze: jest.fn(() => Promise.resolve({ sentiment: 'bullish' }))
}
});
});
test('handles trading signals correctly', async () => {
// Your test implementation
});
});# Prepare for publishing
npm run build
npm run validate --strict
# Publish to marketplace
defai-element publish \
--tier bronze \
--price 150 \
--royalty 10 \
--description "AI-powered trading workspace"
# Update existing element
defai-element update --version patch- π° One-time Purchase - Users buy element permanently
- π Subscription Model - Monthly/yearly recurring revenue
- π Usage-based Pricing - Pay per transaction/analysis
- π― Freemium - Basic free, premium features paid
- π Premium Tiers - Multiple feature levels
- π Trading & DeFi - Trading tools, portfolio managers, DeFi protocols
- π€ AI & Analytics - Market analysis, predictive models, data visualization
- π§ Productivity Tools - Task managers, calculators, converters
- π¬ Communication - Chat widgets, social feeds, collaboration tools
# Clone your element project
git clone https://github.com/yourusername/my-element.git
cd my-element
# Install dependencies
npm install
# Start development server (with hot reload)
npm run dev
# OR using CLI
defai-element dev --port 3000 --open
# Run tests in watch mode
npm run test:watch
# OR using CLI
defai-element test --watch --coverage# Create optimized build
npm run build
# OR using CLI with analysis
defai-element build --analyze --source-maps
# Validate the build
defai-element validate --strict
# Test the production build locally
defai-element serve dist/# .github/workflows/element-ci.yml
name: Element CI/CD
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install DEFAI CLI
run: npm install -g @defai/element-cli
- name: Install dependencies
run: npm ci
- name: Run tests
run: defai-element test --coverage
- name: Validate element
run: defai-element validate --strict
- name: Build production
run: defai-element build
- name: Publish (on main branch)
if: github.ref == 'refs/heads/main'
run: defai-element publish
env:
DEFAI_API_KEY: ${{ secrets.DEFAI_API_KEY }}We welcome contributions from the community! Here's how to get involved:
# Clone the SDK repository
git clone https://github.com/defaiza/element-sdk
cd element-sdk
# Install dependencies
npm install
# Build all packages
npm run build
# Run tests
npm run test
# Start development
npm run dev- Fork the Repository - Create your own fork to work on
- Create Feature Branch -
git checkout -b feature/amazing-feature - Follow Code Standards - Use our ESLint and Prettier configs
- Add Tests - Ensure your changes have proper test coverage
- Update Documentation - Keep docs in sync with code changes
- Submit Pull Request - Describe your changes and their impact
- π Bug Fixes - Help us squash bugs and improve stability
- π Documentation - Improve guides, examples, and API docs
- π§ͺ Testing - Expand test coverage and add integration tests
- π New Features - Propose and implement new SDK capabilities
- π¨ Templates - Create new element templates for different use cases
- π Documentation - docs.defai.com/elements
- π¬ Discord Community - discord.gg/defai
- π GitHub Issues - github.com/defaiza/element-sdk/issues
- π§ Developer Support - developers@defai.com
- π Tutorials - Step-by-step guides for all skill levels
- π‘ Examples Gallery - Showcase of amazing community elements
- π£οΈ Developer Forum - Ask questions and share knowledge
- π Developer Events - Regular workshops and hackathons
- π Bounty Program - Earn tokens for completing development tasks
Join our weekly developer office hours:
- When: Every Friday 2PM UTC
- Where: Discord #dev-office-hours
- What: Get help, ask questions, share your progress
This project is licensed under the MIT License - see the LICENSE file for details.
Ready to build the future of decentralized AI? Start with our sample workspace template and apply for a DEFAI Builder Grant today! π
Earn up to 100,000 DEFAI tokens while building the elements that will power tomorrow's decentralized economy.
