Transactions API

Overview

Endpoints for managing blockchain transactions, including transfers, gas estimation, and transaction history.

Send Transaction

Send a raw transaction to the blockchain.

POST api.bloclabs.com/v1/wallets/{wallet_id}/send-transaction

Request

{
    "to": "0x789...def",
    "value": "1.5",
    "asset": "ETH",
    "gas_priority": "MEDIUM",     // LOW, MEDIUM, HIGH, URGENT
    "data": "0x...",             // Optional: Contract interaction data
    "nonce": 5,                  // Optional: Custom nonce
    "max_fee_per_gas": "50",     // Optional: In GWEI
    "max_priority_fee": "2"      // Optional: In GWEI
}

Response

{
    "status": "success",
    "data": {
        "transaction_id": "tx_xyz789",
        "hash": "0xabc...123",
        "from": "0x123...abc",
        "to": "0x789...def",
        "value": "1.5",
        "asset": "ETH",
        "status": "PENDING",
        "created_at": "2024-03-15T10:00:00Z",
        "estimated_completion_time": "2024-03-15T10:01:00Z"
    }
}

Transfer Assets

High-level endpoint for token transfers.

POST api.bloclabs.com/v1/wallets/{wallet_id}/transfer

Request

{
    "to": "0x789...def",
    "amount": "1000.00",
    "asset": "USDC",             // Token symbol or address
    "gas_priority": "MEDIUM",
    "memo": "Payment for services", // Optional: Transaction note
    "notification": {              // Optional: Notification preferences
        "email": true,
        "push": true
    }
}

Response

{
    "status": "success",
    "data": {
        "transfer_id": "transfer_abc123",
        "transaction_hash": "0xabc...123",
        "from": "0x123...abc",
        "to": "0x789...def",
        "amount": "1000.00",
        "asset": "USDC",
        "usd_value": "1000.00",
        "status": "PENDING",
        "estimated_completion_time": "2024-03-15T10:01:00Z"
    }
}

Estimate Gas

Estimate gas fees for a transaction.

POST api.bloclabs.com/v1/wallets/{wallet_id}/estimate-gas

Request

{
    "to": "0x789...def",
    "value": "1.5",
    "asset": "ETH",
    "data": "0x...",           // Optional: Contract interaction data
    "gas_priority": "MEDIUM"
}

Response

{
    "status": "success",
    "data": {
        "estimated_gas": "21000",
        "gas_prices": {
            "low": {
                "max_fee": "30",
                "max_priority_fee": "1",
                "estimated_seconds": 60
            },
            "medium": {
                "max_fee": "50",
                "max_priority_fee": "2",
                "estimated_seconds": 30
            },
            "high": {
                "max_fee": "70",
                "max_priority_fee": "3",
                "estimated_seconds": 15
            }
        },
        "estimated_cost": {
            "eth": "0.00105",
            "usd": "2.10"
        }
    }
}

Get Transaction Status

Check the status of a specific transaction.

GET api.bloclabs.com/v1/wallets/transaction/{tx_hash}

Response

{
    "status": "success",
    "data": {
        "hash": "0xabc...123",
        "status": "CONFIRMED",
        "block_number": 15481234,
        "confirmations": 12,
        "from": "0x123...abc",
        "to": "0x789...def",
        "value": "1.5",
        "asset": "ETH",
        "gas_used": "21000",
        "gas_price": "50",
        "timestamp": "2024-03-15T10:01:00Z"
    }
}

Get Transaction History

Retrieve transaction history for a wallet.

GET api.bloclabs.com/v1/wallets/{wallet_id}/history

Query Parameters

{
    "type": "all",           // all, sent, received
    "asset": "ETH",         // Optional: Filter by asset
    "from_date": "2024-03-01", // Optional: Start date
    "to_date": "2024-03-15",   // Optional: End date
    "limit": 10,               // Optional: Number of results
    "offset": 0                // Optional: Pagination offset
}

Response

{
    "status": "success",
    "data": {
        "transactions": [
            {
                "hash": "0xabc...123",
                "type": "SENT",
                "status": "CONFIRMED",
                "from": "0x123...abc",
                "to": "0x789...def",
                "value": "1.5",
                "asset": "ETH",
                "usd_value": "3000.00",
                "timestamp": "2024-03-15T10:01:00Z",
                "gas_used": "21000",
                "gas_price": "50"
            }
        ],
        "pagination": {
            "total": 50,
            "limit": 10,
            "offset": 0
        }
    }
}

Error Responses

Insufficient Funds

{
    "status": "error",
    "message": "Insufficient funds for transaction",
    "code": "INSUFFICIENT_FUNDS",
    "data": {
        "required": "1.5 ETH",
        "available": "1.0 ETH"
    }
}

Transaction Failed

{
    "status": "error",
    "message": "Transaction failed",
    "code": "TRANSACTION_FAILED",
    "data": {
        "reason": "Contract execution reverted",
        "gas_used": "21000"
    }
}

Invalid Gas Price

{
    "status": "error",
    "message": "Gas price too low",
    "code": "INVALID_GAS_PRICE",
    "data": {
        "minimum_gas_price": "30 GWEI"
    }
}

Notes

  • Always estimate gas before sending transactions

  • Transactions are irreversible once confirmed

  • Gas prices can fluctuate rapidly

  • Keep track of nonce for multiple transactions

Last updated

Was this helpful?