vernachain

Vernachain API Reference

This document provides detailed information about the Vernachain API endpoints, request/response formats, and authentication methods.

Table of Contents

Authentication

All API requests require an API key to be included in the header:

X-API-Key: your_api_key_here

Rate limits:

Base URLs

Node API

Get Node Status

GET /node/status

Response:

{
  "node_id": "string",
  "version": "string",
  "peers_count": 0,
  "is_syncing": false,
  "latest_block": 0,
  "uptime": 0
}

Get Peers List

GET /node/peers

Response:

{
  "peers": [
    {
      "node_id": "string",
      "address": "string",
      "port": 0,
      "last_seen": "timestamp"
    }
  ]
}

Blockchain API

Get Block

GET /blocks/{block_id}

Response:

{
  "index": 0,
  "hash": "string",
  "previous_hash": "string",
  "timestamp": "timestamp",
  "transactions": [],
  "validator": "string",
  "signature": "string"
}

Get Transaction

GET /transactions/{tx_hash}

Response:

{
  "hash": "string",
  "from": "string",
  "to": "string",
  "value": "number",
  "timestamp": "timestamp",
  "block_hash": "string",
  "status": "string"
}

Send Transaction

POST /transactions

Request:

{
  "from": "string",
  "to": "string",
  "value": "number",
  "data": "string",
  "signature": "string"
}

Wallet API

Get Balance

GET /wallets/{address}/balance

Response:

{
  "address": "string",
  "balance": "number",
  "staked": "number",
  "nonce": 0
}

Get Transaction History

GET /wallets/{address}/transactions

Parameters:

Smart Contract API

Deploy Contract

POST /contracts/deploy

Request:

{
  "bytecode": "string",
  "abi": "string",
  "constructor_args": "string",
  "sender": "string",
  "signature": "string"
}

Call Contract

POST /contracts/{address}/call

Request:

{
  "function": "string",
  "args": "string",
  "sender": "string",
  "signature": "string"
}

Get Contract

GET /contracts/{address}

Response:

{
  "address": "string",
  "creator": "string",
  "created_at": "timestamp",
  "abi": "string",
  "bytecode": "string"
}

Bridge API

Initiate Transfer

POST /bridge/transfer

Request:

{
  "from_chain": "string",
  "to_chain": "string",
  "token": "string",
  "amount": "number",
  "recipient": "string",
  "signature": "string"
}

Get Transfer Status

GET /bridge/transfers/{tx_hash}

Response:

{
  "hash": "string",
  "status": "string",
  "from_chain": "string",
  "to_chain": "string",
  "amount": "number",
  "timestamp": "timestamp"
}

WebSocket Events

Connect to WebSocket endpoint:

ws://localhost:8000/ws

Subscribe to Events

{
  "type": "subscribe",
  "channels": [
    "blocks",
    "transactions",
    "validators"
  ]
}

Event Types

  1. New Block Event:
    {
      "type": "block",
      "data": {
     "index": 0,
     "hash": "string",
     "transactions": []
      }
    }
    
  2. New Transaction Event:
    {
      "type": "transaction",
      "data": {
     "hash": "string",
     "from": "string",
     "to": "string",
     "value": "number"
      }
    }
    
  3. Validator Event:
    {
      "type": "validator",
      "data": {
     "address": "string",
     "action": "string",
     "stake": "number"
      }
    }
    

Error Handling

All API errors follow this format:

{
  "error": {
    "code": "string",
    "message": "string",
    "details": {}
  }
}

Common Error Codes:

Pagination

For endpoints that return lists, use these query parameters:

Response format includes pagination metadata:

{
  "data": [],
  "pagination": {
    "total": 0,
    "limit": 0,
    "offset": 0,
    "has_more": false
  }
}

Rate Limiting

Response headers include rate limit information:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 99
X-RateLimit-Reset: 1635724800