Workflow DSL
Structure of the DeFi Risk Alert workflow.
defi-risk-alert.yaml
# Example: DeFi Risk Alert Smart Workflow
name: DeFi Risk Alert
# Authorization & Payment
authority:
uses: w3-io/actions/authority/ed25519@v1
with:
pubkey: 0x892b3c5e8d1f4a7c9e2b6d8a3f5c7e9b4d6a8c1e3b5d7a9c2e4f6b8d1a3c5e7
payer:
uses: w3-io/actions/payer/account@v1
with:
pubkey: 0x6d9a2c5e8f1b4d7a0c3e6b9d2f5a8c1e4b7d0a3c6e9f2b5d8a1c4e7f0b3d6a9
# Secrets (encrypted, decrypted only in TEE)
secrets:
- HYPERBOLIC_API_KEY # Decentralized AI inference
- SENDGRID_API_KEY # Email delivery
- ALCHEMY_API_KEY # Blockchain data
- PRIVATE_KEY_WALLET # Trade execution
# Encrypted at rest, only decrypted inside TEE during execution
# Authority signature required to access secrets
on:
ethereum:
contract: 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 # USDC
event: Transfer
jobs:
alert-workflow:
runs-on: w3-io-validator-network
# Each step below is a "Smart Action" - a verifiable computation unit
# Note: Smart contracts can be Smart Actions (e.g., Ethereum transactions)
steps:
# STEP 1: Blockchain read
- name: Check USDC balance
uses: w3-io/actions/ethereum/contract-call@v1
with:
contract: 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
function_signature: balanceOf(address)
parameters:
- 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb2
block: 18500123
# STEP 2: Hyperbolic AI inference
- name: Risk analysis with Hyperbolic AI
uses: w3-io/actions/ai/hyperbolic@v1
with:
model: meta-llama/Llama-3.3-70B-Instruct
prompt: |
Analyze DeFi transaction risk:
Balance: ${{ steps.check-usdc-balance.outputs.result }}
Contract: 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
Provide risk score 0-100 with reasoning.
api_key: ${{ secrets.HYPERBOLIC_API_KEY }}
replicas: 3
# 🔒 Runs on decentralized Hyperbolic GPU network, not AWS/OpenAI
# STEP 3: External API
- name: Send email alert
uses: w3-io/actions/external/sendgrid@v1
with:
to: trader@example.com
subject: Risk Alert
risk_analysis: ${{ steps.risk-analysis-hyperbolic.outputs.output }}
api_key: ${{ secrets.SENDGRID_API_KEY }}
# 🔒 API key decrypted inside TEE, never exposed to validator
# STEP 4: Onchain transaction
- name: Execute hedge trade
uses: w3-io/actions/ethereum/contract-transaction@v1
with:
contract: 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D # Uniswap V2
from: 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb2
function_signature: swapExactTokensForTokens(uint256,uint256,address[],address,uint256)
parameters:
- 1000000000 # Amount in
- 990000000 # Min amount out
- [0xA0b8..., 0xC02a...] # Path
- 0x742d35Cc... # Recipient
- 1699999999 # Deadline
gas_limit: 200000
private_key: ${{ secrets.PRIVATE_KEY_WALLET }}
# 🔒 Private key signs tx inside TEE, never exposed to validator