BlockonomicsAPI Reference
Guides

Web3 USDT Component

Embed a ready-made Web3 component that lets customers pay USDT from MetaMask or any browser wallet.


Overview

The Web3 USDT Component handles wallet connection, network validation, and ERC-20 transfer signing in a single embeddable element. Drop it on your USDT checkout page and it takes care of the browser wallet interaction.

Embed the Component

html
<!-- Include the component script -->
<script src="https://blockonomics.co/js/web3-payment.js"></script>

<!-- Place the component in your HTML -->
<web3-payment
  id="web3_payment"
  order_amount="10"
  receive_address="YOUR_USDT_RECEIVE_ADDRESS"
  testnet="0"
></web3-payment>

Attributes

AttributeDescription
order_amountAmount of USDT the customer must pay
receive_addressYour USDT (ERC-20) receiving address
testnet0 for Ethereum mainnet, 1 for Sepolia testnet

Handle Payment Submission

When the customer approves the transaction in their wallet, the component fires onTxnSubmitted with the txhash and crypto:

javascript
const web3Payment = document.getElementById('web3_payment');

web3Payment.onTxnSubmitted = function(result) {
  const { crypto, txhash } = result;

  // Send to your backend for monitoring
  fetch('/api/payments/confirm', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ txhash, crypto })
  });
};

Backend: Register for Monitoring

Your backend must submit the txhash to Blockonomics so it can track confirmation and send a callback. Call Monitor USDT Transaction:

bash
curl -X POST "https://www.blockonomics.co/api/monitor_tx" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"txid": "TX_HASH", "crypto": "USDT"}'

Once registered, Blockonomics sends a callback to your server when the transaction confirms on-chain. Mark the order as paid at that point — not when onTxnSubmitted fires.