Node.js
import { createHmac } from "node:crypto";
// Node.js 18+. Set credentials and resource values on your server.
function required(name) {
const value = process.env[name];
if (!value) throw new Error(`Set ${name} before running this example.`);
return value;
}
const baseUrl = process.env.LEDIG_API_BASE_URL ?? "https://api-sandbox.ledig.io";
const method = "POST";
const path = `/v1/wallets/network`;
const pathWithQuery = path;
// Choose the network and supported asset returned by GET /v1/wallets/options in this environment.
const body = {
"nickname": "Customer deposits",
"network": required("LEDIG_DEPOSIT_NETWORK")
};
const rawBody = JSON.stringify(body);
const headers = { "Accept": "application/json" };
headers["Content-Type"] = "application/json";
// Keep this value and the same body when retrying this request.
headers["Idempotency-Key"] = required("LEDIG_IDEMPOTENCY_KEY");
const timestamp = Math.floor(Date.now() / 1000).toString();
const payload = `${timestamp}.${method}.${pathWithQuery}.${rawBody}`;
headers["x-ledig-key"] = required("LEDIG_API_KEY");
headers["x-ledig-timestamp"] = timestamp;
headers["x-ledig-signature"] = "v1=" + createHmac("sha256", required("LEDIG_API_SECRET"))
.update(payload).digest("base64");
const response = await fetch(`${baseUrl}${pathWithQuery}`, {
method,
headers,
body: rawBody,
});
const result = await response.json();
// Use result in your application; do not log credentials or upload links.
console.log(response.status);{
"status": "success",
"data": {
"requestId": "wallet_request_example_001",
"status": "ready",
"network": "ETHEREUM_SEPOLIA",
"address": "0x1111111111111111111111111111111111111111",
"supportedAssets": [
{
"code": "USDC",
"name": "USD Coin",
"testToken": true
}
],
"wallets": [
{
"id": "wallet_example_001",
"nickname": "Customer deposits",
"coin": "USDC",
"network": "ETHEREUM_SEPOLIA",
"address": "0x1111111111111111111111111111111111111111",
"memo": "",
"createdAt": "2026-01-15T10:00:00.000Z",
"updatedAt": "2026-01-15T10:00:00.000Z"
}
]
}
}{
"status": "success",
"data": {
"requestId": "wallet_request_example_001",
"status": "pending",
"network": "ETHEREUM_SEPOLIA",
"address": null,
"supportedAssets": [
{
"code": "USDC",
"name": "USD Coin",
"testToken": true
}
],
"wallets": [],
"setupState": "processing"
}
}{
"status": "error",
"code": "BAD_REQUEST",
"message": "Check the request fields and try again."
}{
"status": "error",
"code": "UNAUTHORIZED",
"message": "Authentication is required."
}{
"status": "error",
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action."
}{
"status": "error",
"code": "CONFLICT",
"message": "The request conflicts with the current state of this resource."
}{
"status": "error",
"code": "RATE_LIMITED",
"message": "Too many requests. Wait before trying again."
}{
"status": "error",
"code": "PROVIDER_UNAVAILABLE",
"message": "This service is temporarily unavailable. Please try again later."
}Deposit wallets
Create a network deposit address
Set up one deposit address for a network’s supported assets.
POST
/
v1
/
wallets
/
network
Node.js
import { createHmac } from "node:crypto";
// Node.js 18+. Set credentials and resource values on your server.
function required(name) {
const value = process.env[name];
if (!value) throw new Error(`Set ${name} before running this example.`);
return value;
}
const baseUrl = process.env.LEDIG_API_BASE_URL ?? "https://api-sandbox.ledig.io";
const method = "POST";
const path = `/v1/wallets/network`;
const pathWithQuery = path;
// Choose the network and supported asset returned by GET /v1/wallets/options in this environment.
const body = {
"nickname": "Customer deposits",
"network": required("LEDIG_DEPOSIT_NETWORK")
};
const rawBody = JSON.stringify(body);
const headers = { "Accept": "application/json" };
headers["Content-Type"] = "application/json";
// Keep this value and the same body when retrying this request.
headers["Idempotency-Key"] = required("LEDIG_IDEMPOTENCY_KEY");
const timestamp = Math.floor(Date.now() / 1000).toString();
const payload = `${timestamp}.${method}.${pathWithQuery}.${rawBody}`;
headers["x-ledig-key"] = required("LEDIG_API_KEY");
headers["x-ledig-timestamp"] = timestamp;
headers["x-ledig-signature"] = "v1=" + createHmac("sha256", required("LEDIG_API_SECRET"))
.update(payload).digest("base64");
const response = await fetch(`${baseUrl}${pathWithQuery}`, {
method,
headers,
body: rawBody,
});
const result = await response.json();
// Use result in your application; do not log credentials or upload links.
console.log(response.status);{
"status": "success",
"data": {
"requestId": "wallet_request_example_001",
"status": "ready",
"network": "ETHEREUM_SEPOLIA",
"address": "0x1111111111111111111111111111111111111111",
"supportedAssets": [
{
"code": "USDC",
"name": "USD Coin",
"testToken": true
}
],
"wallets": [
{
"id": "wallet_example_001",
"nickname": "Customer deposits",
"coin": "USDC",
"network": "ETHEREUM_SEPOLIA",
"address": "0x1111111111111111111111111111111111111111",
"memo": "",
"createdAt": "2026-01-15T10:00:00.000Z",
"updatedAt": "2026-01-15T10:00:00.000Z"
}
]
}
}{
"status": "success",
"data": {
"requestId": "wallet_request_example_001",
"status": "pending",
"network": "ETHEREUM_SEPOLIA",
"address": null,
"supportedAssets": [
{
"code": "USDC",
"name": "USD Coin",
"testToken": true
}
],
"wallets": [],
"setupState": "processing"
}
}{
"status": "error",
"code": "BAD_REQUEST",
"message": "Check the request fields and try again."
}{
"status": "error",
"code": "UNAUTHORIZED",
"message": "Authentication is required."
}{
"status": "error",
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action."
}{
"status": "error",
"code": "CONFLICT",
"message": "The request conflicts with the current state of this resource."
}{
"status": "error",
"code": "RATE_LIMITED",
"message": "Too many requests. Wait before trying again."
}{
"status": "error",
"code": "PROVIDER_UNAVAILABLE",
"message": "This service is temporarily unavailable. Please try again later."
}Required scope:
wallets:write
Send network, nickname, optional memo and an Idempotency-Key. The request keeps the supported asset set chosen when it is accepted. HTTP 201 means the address is ready; HTTP 202 means setup is pending. After a timeout, retry with the original key and body. Once requestId is known, use GET /v1/wallets/network/. For pending requests, setupState=processing means continue polling the same request; review_required means Ledig must review it. Retain the requestId and do not create a replacement. Creating an address does not add funds to your balance.Authorizations
Headers
Body
application/json