A Node.js application that provides an API for verifying and storing x42 blockchain snapshot information. The API validates x42 addresses, verifies balances against the x42 network, and stores verified snapshots in PostgreSQL. Successful verifications trigger Discord notifications.
- Node.js (v14 or higher)
- PostgreSQL database
- x42 node with addressindex enabled
- Discord webhook URL (for notifications)
- Clone the repository:
git clone https://github.com/EpixZone/Claimer-API.git
cd Claimer-API
- Install dependencies:
npm install
- Create a
.env
file in the root directory:
DB_NAME=your_database_name
DB_USER=your_database_user
DB_PASSWORD=your_database_password
DB_HOST=localhost
DB_PORT=5432
NODE_HOST=http://localhost:42220
DISCORD_WEBHOOK_URL=your_discord_webhook_url
PORT=3000
SWAGGER_HOST=http://localhost:3000
- Enable address indexing in your x42.conf file:
addressindex=1
- Restart your x42 node after making this change
- Create a PostgreSQL database:
CREATE DATABASE your_database_name;
- The tables will be automatically created when you first run the application
node index.js
# Run all tests
npm test
# Run specific test file
npm test tests/discord.test.js
# Run tests in watch mode
npm run test:watch
Access the interactive API documentation at:
http://localhost:3000/api-docs
Verifies and stores snapshot information
Request Body:
{
"x42_address": "XG9pb7U3F32QQ4dShADV2v71hdLAFQA2Gf",
"epix_address": "epix1r2357f40wpkruzxu6ss87rvf0hp7hnln246h4x",
"snapshot_balance": 69223563046
}
Headers:
signature
: Required. Cryptographic signature for verification
Responses:
200
: Snapshot verified and stored successfully400
: Validation error (invalid signature, balance mismatch, etc.)500
: Internal server error
Checks the balance of a given address
Parameters:
address
: x42 address to check
Verifies if an address is valid and not a witness
Parameters:
address
: Address to verify
Returns total claimed amount and number of claims
Returns paginated list of claims with signatures
Parameters:
page
: Page number (default: 1)pageSize
: Items per page (default: 10)
Returns current block height of the address indexer
Downloads a CSV file of all snapshots
The snapshot verification process is designed to ensure accurate balance verification using the x42 blockchain. Here's a detailed breakdown of how balances are verified:
- The API verifies the block height is exactly 3,000,000
- The API queries the x42 node using the BlockCore API endpoint:
Example:
GET api/BlockStore/getaddressesbalances?addresses=[Address]&minConfirmations=1
http://localhost:42220/api/BlockStore/getaddressesbalances?addresses=XG9pb7U3F32QQ4dShADV2v71hdLAFQA2Gf&minConfirmations=1
- The returned balance is compared with the claimed snapshot_balance
- The transaction must be signed by the address owner to prove ownership
To support balance verification, your x42 node must:
- Have
addressindex
enabled in x42.conf:addressindex=1
- Be fully synced to block height 3,000,000
- Have the BlockCore API accessible (default port: 42220)
- Validates the x42 address format
- Verifies the current block height is at 3,000,000
- Checks if the claim period is still active (before February 10th, 2025)
- Verifies the address hasn't been previously claimed
- Validates the balance against the x42 network using BlockCore API
- Verifies the cryptographic signature
- Stores the verified snapshot
- Sends a Discord notification on successful verification
Discord notifications are handled by a separate utility function in utils/discord.js
. You can test this functionality independently:
const { sendSnapshotVerificationNotification } = require('./utils/discord');
// Test the notification
await sendSnapshotVerificationNotification('x42_address', balance);
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request