Event from Wallet Service (TOPUP)
Accepts incoming on-chain events. Currently only TOPUP is processed. NO auth/signature (demo; HMAC will be added in production). Body validation is done manually inside the handler (external contract, no strict schema is enforced).
The token is resolved from the registry by contract address (preferred) or by code (fallback with a warning); an unknown token is ignored.
Crediting is a topup ledger entry in an atomic batch: address:available ← vault:external. For the address's primary token, the balance comes from the ledger; for a "non-primary" token (asset_mismatch), funds are tracked in a separate ledger account and visible in GET /vaults/{code}/balances.
Idempotency: unique(network, txHash) and unique(webhookEventId); a duplicate returns 200 {duplicate: true}. TRX events and unknown addresses are ignored (200 {ignored: true}).
curl -X POST "https://policy-engine-rest.ezig.workers.dev/webhooks/wallet" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-d '{
"tx": {
"network": "TRON",
"asset": "USDT",
"contract": "example_string",
"type": "example_string",
"id": "example_string",
"block": 42,
"timestamp": 3.14,
"from": "example_string",
"to": "example_string",
"value": "example_string"
}
}'
import requests
import json
url = "https://policy-engine-rest.ezig.workers.dev/webhooks/wallet"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_TOKEN"
}
data = {
"tx": {
"network": "TRON",
"asset": "USDT",
"contract": "example_string",
"type": "example_string",
"id": "example_string",
"block": 42,
"timestamp": 3.14,
"from": "example_string",
"to": "example_string",
"value": "example_string"
}
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
const response = await fetch("https://policy-engine-rest.ezig.workers.dev/webhooks/wallet", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_TOKEN"
},
body: JSON.stringify({
"tx": {
"network": "TRON",
"asset": "USDT",
"contract": "example_string",
"type": "example_string",
"id": "example_string",
"block": 42,
"timestamp": 3.14,
"from": "example_string",
"to": "example_string",
"value": "example_string"
}
})
});
const data = await response.json();
console.log(data);
package main
import (
"fmt"
"net/http"
"bytes"
"encoding/json"
)
func main() {
data := []byte(`{
"tx": {
"network": "TRON",
"asset": "USDT",
"contract": "example_string",
"type": "example_string",
"id": "example_string",
"block": 42,
"timestamp": 3.14,
"from": "example_string",
"to": "example_string",
"value": "example_string"
}
}`)
req, err := http.NewRequest("POST", "https://policy-engine-rest.ezig.workers.dev/webhooks/wallet", bytes.NewBuffer(data))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer YOUR_API_TOKEN")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}
require 'net/http'
require 'json'
uri = URI('https://policy-engine-rest.ezig.workers.dev/webhooks/wallet')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/json'
request['Authorization'] = 'Bearer YOUR_API_TOKEN'
request.body = '{
"tx": {
"network": "TRON",
"asset": "USDT",
"contract": "example_string",
"type": "example_string",
"id": "example_string",
"block": 42,
"timestamp": 3.14,
"from": "example_string",
"to": "example_string",
"value": "example_string"
}
}'
response = http.request(request)
puts response.body
{
"ok": true,
"incomingId": "example_string",
"balanceUpdated": true,
"newBalance": "example_string"
}
{
"ok": true,
"incomingId": "example_string",
"balanceUpdated": true,
"reason": "example_string",
"ledgerRecorded": true,
"addressAsset": "123 Main St",
"receivedAsset": "example_string"
}
{
"ignored": true,
"reason": "trx_events_disabled"
}
{
"duplicate": true,
"eventId": "example_string"
}
{
"error": "Bad Request",
"message": "The request contains invalid parameters or malformed data",
"code": 400,
"details": [
{
"field": "email",
"message": "Invalid email format"
}
]
}
{
"error": "Internal Server Error",
"message": "An unexpected error occurred on the server",
"code": 500,
"requestId": "req_1234567890"
}
/webhooks/wallet
Target server for requests. Edit to use your own host.
Session token. Mobile/services. The web uses a cookie.
API key (sent in cookie)
The media type of the request body
Request Preview
Response
Response will appear here after sending the request
Authentication
Bearer token. Session token. Mobile/services. The web uses a cookie.
API Key for authentication. Provide your API key in the cookie.