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`;
const pathWithQuery = path;
// Choose the network and supported asset returned by GET /v1/wallets/options in this environment.
const body = {
"nickname": "Customer deposits",
"coin": required("LEDIG_DEPOSIT_ASSET"),
"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": {
"id": "wallet_example_001",
"profileId": "profile_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": "error",
"code": "BAD_REQUEST",
"message": "This asset is not supported for deposits on this network.",
"details": {
"reason": "unsupported_asset_network"
}
}{
"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": "RATE_LIMITED",
"message": "Too many requests. Wait before trying again."
}{
"status": "error",
"code": "PROVIDER_UNAVAILABLE",
"message": "Wallet creation is temporarily unavailable."
}Deposit wallets
Create a crypto deposit address
Get a deposit address for one asset and network.
POST
/
v1
/
wallets
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`;
const pathWithQuery = path;
// Choose the network and supported asset returned by GET /v1/wallets/options in this environment.
const body = {
"nickname": "Customer deposits",
"coin": required("LEDIG_DEPOSIT_ASSET"),
"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": {
"id": "wallet_example_001",
"profileId": "profile_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": "error",
"code": "BAD_REQUEST",
"message": "This asset is not supported for deposits on this network.",
"details": {
"reason": "unsupported_asset_network"
}
}{
"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": "RATE_LIMITED",
"message": "Too many requests. Wait before trying again."
}{
"status": "error",
"code": "PROVIDER_UNAVAILABLE",
"message": "Wallet creation is temporarily unavailable."
}Required scope:
wallets:write
Send an Idempotency-Key. Retrying the same request with the same key returns the same wallet; reusing the key with different inputs returns 409. Choose the asset and network from GET /v1/wallets/options. A new request for an unsupported pair returns 400 BAD_REQUEST with details.reason=unsupported_asset_network; correct the pair instead of retrying it unchanged. HTTP 503 PROVIDER_UNAVAILABLE means setup is temporarily unavailable; retry with the same key and body. If the response includes a memo or tag, include it with every deposit. Funds received at the address belong to your business balance; the address does not have a separate balance.