TxRelay API

Secure, Non-Custodial Blockchain Transaction Service

Version 2.2 Ethereum Polygon Base Testnets ERC-20

Introduction

TxRelay API allows you to build and broadcast blockchain transactions without sharing your private keys. We handle:

How it works:

  1. You call /prepare → We return an unsigned transaction.
  2. You sign it locally with your private key.
  3. You call /broadcast → We send it to the blockchain.

Official SDK

The easiest way to use TxRelay. Full TypeScript support with autocomplete.

npm install txrelay-sdk
import { TxRelay } from 'txrelay-sdk';

const client = new TxRelay('YOUR_API_KEY');

// Prepare a transaction
const { unsignedTx } = await client.prepareTransaction({
  from: '0xYourWallet...',
  to: '0xRecipient...',
  amount: '0.1',
  chain: 'ethereum'
});

// Sign locally with ethers.js
const signedTx = await wallet.signTransaction(unsignedTx);

// Broadcast
const { txHash } = await client.broadcastTransaction({
  signedTx,
  chain: 'ethereum'
});

// Check balance
const { balance } = await client.getBalance('0x...', 'ethereum');

// Account info
const account = await client.getAccount();

Authentication

All API requests require an API key in the header:

x-api-key: YOUR_API_KEY

Get your API key from the Dashboard.

Supported Chains

Chain ID Currency Type
ethereum1ETHMainnet
polygon137POLMainnet
base8453ETHMainnet
sepolia11155111ETHTestnet
amoy80002POLTestnet

API Endpoints

Base URL: https://api.txrelay-api.com/api/v1

Transactions

POST /transactions/prepare

Prepares an unsigned native currency transaction.

// Request
{
  "from": "0xYourWallet...",
  "to": "0xRecipient...",
  "amount": "0.1",
  "chain": "ethereum"
}

// Response
{
  "unsignedTx": { ... },
  "metadata": {
    "estimatedFee": "0.0001",
    "totalCost": "0.1001"
  }
}
POST /transactions/prepare-token

Prepares an unsigned ERC-20 token transaction.

// Request
{
  "from": "0xYourWallet...",
  "to": "0xRecipient...",
  "amount": "100",
  "tokenAddress": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
  "chain": "ethereum"
}
POST /transactions/broadcast

Broadcasts a signed transaction to the network.

// Request
{
  "signedTx": "0x02f8...",
  "chain": "ethereum"
}

// Response
{
  "txHash": "0x...",
  "status": "queued"
}
GET /transactions

Lists your transaction history.

Query params: ?limit=50&offset=0&status=confirmed&chain=ethereum

Balance & Account

GET /balance/:address

Gets native currency balance. Query: ?chain=ethereum

GET /me

Gets your API key info and usage statistics.

Webhooks

Receive real-time notifications when transactions are confirmed.

POST /webhooks

Creates a webhook subscription. Returns a secret - save it!

GET /webhooks

Lists all your active webhooks.

DELETE /webhooks/:id

Deletes a webhook.

Webhook Payload

{
  "id": "evt_...",
  "event": "transaction.confirmed",
  "created_at": 1702000000,
  "data": {
    "txHash": "0x...",
    "status": "confirmed",
    "blockNumber": 12345678
  }
}

Verifying Signatures

We sign every webhook with your secret. Header: X-TxRelay-Signature

// Node.js
const crypto = require('crypto');
const [tPart, sigPart] = signature.split(',');
const timestamp = tPart.split('=')[1];
const sig = sigPart.split('=')[1];

const expected = crypto
  .createHmac('sha256', YOUR_WEBHOOK_SECRET)
  .update(`${timestamp}.${JSON.stringify(body)}`)
  .digest('hex');

if (sig === expected) { /* Verified */ }

Error Codes

CodeErrorDescription
400ValidationErrorInvalid request parameters
401UnauthorizedMissing or invalid API key
403ForbiddenAPI key deactivated or IP blocked
404NotFoundResource not found
409DuplicateTransactionTransaction already exists
429RateLimitExceededToo many requests (see headers)
429MonthlyLimitExceededMonthly quota reached
500ServerErrorInternal error (contact support)

All errors return:

{
  "success": false,
  "error": "ValidationError",
  "message": "Invalid wallet address"
}

Rate Limits & Pricing

PlanBurst (per min)MonthlyPriceSupport
Free30100€0Email
Pro12010,000€29/moEmail
Enterprise6001,000,000+€199/moEmail

Rate limit headers are included in every response:

X-RateLimit-Limit: 30
X-RateLimit-Remaining: 25
X-RateLimit-Reset: 2025-12-08T01:00:00Z
X-Monthly-Limit: 100
X-Monthly-Used: 42