Relayer API Reference

Overview

Complete API documentation for the Meta Transaction Relayer, featuring gas compensation, multi-source price oracle, and comprehensive cost estimation.

🚀 Core Features

  • Gas Compensation System: Configurable multiplier ensures relayer sustainability

  • Multi-Source Price Oracle: CoinGecko, Chainlink, and CoinMarketCap integration

  • Comprehensive Cost Estimation: Detailed transaction cost analysis

  • Credit Management: Token-based gas credit system

  • Multi-Chain Support: Ethereum, BSC, Polygon, Arbitrum, Optimism, Base, Avalanche

📡 API Endpoints

Meta Transaction API Host

https://relayer.dinetwork.tech

Meta Transaction Execution

Execute Meta-Transaction

POST /api/meta-tx/execute

Execute gasless meta-transactions on behalf of users.

Request Body:

MetaTransaction struct:

Response:

Estimate Transaction Cost

Get comprehensive cost estimation including gas compensation and credit requirements. Request Body:

Response:

Key Fields:

  • gasCostNative: Gas cost with compensation multiplier applied

  • hasEnoughCredits: Whether user can afford the transaction

  • creditDeficit: Amount of additional credits needed (if any)

  • breakdown: Detailed USD cost analysis

Get User Nonce

Get the current nonce for a user address.

Response:

Get Transaction Status

Get status and details of a transaction batch.

Response:

Get Transaction Receipt

Get detailed transaction receipt information.

Response:

Credit Management

Get User Credits

Get credit balance for a user address.

Response:

Calculate Credit Value

Calculate credit value for a given token amount.

Request Body:

Response:

Get Whitelisted Tokens

Get list of tokens accepted for credit deposits.

Response:

Price Oracle & Market Data

Get Price Source Status

Check health and status of all price sources for a specific chain.

Response:

Price Sources:

  • CoinGecko: Real-time market data (primary)

  • Chainlink: On-chain price feeds (decentralized)

  • CoinMarketCap: Alternative market data (backup)

Get Current Token Price

Get the current token price for a specific chain.

Response:

Get Multi-Chain Health Overview

Get health status for all supported chains.

Response:

Clear Price Cache (Admin)

Clear the price cache to force fresh price fetching. Requires admin access.

Response:

Utility & System Information

Get Current Gas Prices

Get current gas price for a specific chain.

Response:

Get Supported Chains

Get list of all supported blockchain networks.

Response:

Calculate Transaction Fee

Calculate transaction fees in USD for given gas parameters.

Request Body:

Response:

Detailed Health Check

Get comprehensive system health and status information.

Response:

💰 Gas Compensation System

How It Works

The gas compensation system ensures relayer sustainability by applying a configurable multiplier to gas costs:

  1. Base Calculation: estimatedGas × currentGasPrice

  2. Apply Multiplier: baseCost × gasCompensationMultiplier

  3. Result: Compensated gas cost ensuring profitability

Configuration

Benefits

  • Sustainable Operations: Ensures relayer profitability

  • Covers Operational Costs: Infrastructure and maintenance

  • Market Responsive: Adjustable based on conditions

  • Transparent: Clear compensation methodology

🔍 Multi-Source Price Oracle

Price Source Priority

  1. CoinGecko API - Real-time market data (primary)

  2. Chainlink Price Feeds - On-chain, decentralized

  3. CoinMarketCap API - Alternative market data (backup)

  4. Hardcoded Fallback - Emergency values

Supported Tokens

Chain
Token
CoinGecko ID
Fallback Price

Ethereum

ETH

ethereum

$2,500

BSC

BNB

binancecoin

$300

Polygon

MATIC

matic-network

$0.80

Avalanche

AVAX

avalanche-2

$25

Error Handling

  • Automatic Fallback: Tries next source if one fails

  • Caching: 1-minute cache for reliability

  • Rate Limiting: Prevents API quota exhaustion

  • Graceful Degradation: Always provides a price

🧪 Testing

Test Commands

Test Coverage

  • ✅ Gas compensation calculations

  • ✅ Multi-source price fetching

  • ✅ Credit management

  • ✅ API endpoint validation

  • ✅ Error handling scenarios

  • ✅ Configuration management

🔧 Configuration

Required Environment Variables

Optional API Keys

📊 Response Format

All API responses follow this standardized format:

Success Response

Error Response

Common Error Codes

  • UNSUPPORTED_CHAIN - Chain ID not supported

  • VALIDATION_ERROR - Invalid request parameters

  • INSUFFICIENT_CREDITS - User has insufficient credits

  • EXECUTION_FAILED - Transaction execution failed

  • PRICE_FETCH_FAILED - Unable to fetch current prices

  • NETWORK_ERROR - RPC or network connectivity issues

Last updated