Skip to main content

Quick Start

Get your first HashNut payment working in 5 minutes.

Prerequisites

  • A cryptocurrency wallet (MetaMask for EVM chains, TronLink for TRON)
  • Node.js 18+ (for JavaScript examples) or Python 3.8+ (for Python examples)
  • API credentials (get them from the HashNut Dashboard)

Step 1: Get Your API Credentials

  1. Visit the HashNut Dashboard
  2. Connect your wallet
  3. Create an account (deploys a smart contract)
  4. Generate an API key
  5. Copy your accessKeyId and apiKey

Step 2: Install the SDK

npm install @hashnut/sdk
# or
yarn add @hashnut/sdk

Step 3: Create Your First Payment

import { HashNutClient, HashNutService, CreatePayOrderRequest } from '@hashnut/sdk';

// Initialize SDK
const secretKey = 'YOUR_SECRET_KEY';
const accessKeyId = 'YOUR_ACCESS_KEY_ID';
const testMode = true; // true for testnet

const client = new HashNutClient(secretKey, testMode);
const service = new HashNutService(client);

// Create a payment order
const request = new CreatePayOrderRequest.Builder()
.withAccessKeyId(accessKeyId)
.withMerchantOrderId(`order-${Date.now()}`)
.withChainCode('erc20')
.withCoinCode('usdt')
.withAmount('0.01')
.build();

const response = await service.createPayOrder(request);
const order = response.data;

console.log('Payment URL:', order.paymentUrl);
// Redirect customer to order.paymentUrl

Step 4: Handle the Webhook

When a payment is completed, HashNut will send a webhook to your callBackUrl:

// Express.js example
app.post('/webhook', async (req, res) => {
const { payOrderId, merchantOrderId, state } = req.body;

// Update your database
if (state === 4) { // Payment successful
await updateOrderStatus(merchantOrderId, 'paid');
}

res.send('success');
});

Step 5: Test Your Integration

  1. Create a test order using the code above
  2. Open the payment URL in a browser
  3. Connect your wallet (MetaMask or TronLink)
  4. Complete the payment with test tokens
  5. Check your webhook - you should receive a notification

What's Next?

Need Help?


Congratulations! 🎉 You've created your first HashNut payment. Now explore the full documentation to unlock the full power of HashNut.