Developer quick start
Read the chain from a public node, start a regtest node of your own, send a transaction through the REST API and watch it arrive, in curl, JavaScript and Python.
Ten minutes from nothing to a transaction you built, sent and saw confirmed. Every command on this page was run against the public mainnet API (read-only) and against a regtest node of this release.
1. Read the chain from a public node #
API=https://givelotus.org/api/v1
curl -s $API/chain/tip
curl -s $API/blocks/1433870
curl -s "$API/blocks/1433870/txs?limit=5"
curl -s $API/txs/133d43d6249a12197575abe90d08ee08a6279995e58794b86f754e6943eb23b9
curl -s $API/addresses/lotus_16PSJKoMbdnGyVQyxhuLuZxSuHvqKUy8nv98cXTVmconst API = 'https://givelotus.org/api/v1';
const get = async path => {
const r = await fetch(API + path);
if (!r.ok) throw new Error((await r.json()).error); // stable error code
return r.json();
};
const tip = await get('/chain/tip');
console.log(tip.height, tip.hash);
const a = await get('/addresses/lotus_16PSJKoMbdnGyVQyxhuLuZxSuHvqKUy8nv98cXTVm');
console.log(a.balance_sats, a.tx_count);import json, urllib.request
API = "https://givelotus.org/api/v1"
def get(path):
# Set a User-Agent: the public proxy refuses urllib's default one.
req = urllib.request.Request(API + path, headers={"User-Agent": "my-app/1.0"})
with urllib.request.urlopen(req) as r:
return json.load(r)
tip = get("/chain/tip")
print(tip["height"], tip["hash"])
a = get("/addresses/lotus_16PSJKoMbdnGyVQyxhuLuZxSuHvqKUy8nv98cXTVm")
print(a["balance_sats"], a["tx_count"]){"hash":"0000000000e9ac9a69c67e8ae65ee025b6a356397d79bdd1a8dcf491cd0dbfb9","height":1433879,"time":1795722569,"n_tx":1,"size":959,"previous_hash":"00000000014254ebc30bcda4defc8ebd1d37e8688627c16f0ae97083a24c9445"}Errors always have the same body, {"error": "<code>", "message": "...", "status": <http>}; test error, show message. A 503 with node_warming_up or syncing is temporary: retry after Retry-After. See REST API.
The node can also run any read-only JSON-RPC command for you, without credentials:
curl -s "$API/rpc/getblockhash?0=1"
curl -s "$API/rpc/validateaddress?0=lotus_16PSJKoMbdnGyVQyxhuLuZxSuHvqKUy8nv98cXTVm"2. Run your own regtest node #
Regtest is a private chain where you mine blocks on demand. Use it for everything that sends.
lotusd -regtest -daemon -txindex=1
lotus-cli -regtest createwallet dev
ADDR=$(lotus-cli -regtest getnewaddress)
lotus-cli -regtest generatetoaddress 101 $ADDR # mined coins mature after 100 blocks
lotus-cli -regtest getbalance # 260.000000
API=http://127.0.0.1:12604/api/v1
curl -s $API/healthThe REST API listens on the JSON-RPC port: 10604 on mainnet, 11604 on testnet, 12604 on regtest, on localhost only by default. Regtest addresses start with lotusR.
3. Build, sign and send a transaction #
The node wallet builds and signs here so that the example stays short; your own software would sign with its own keys (Transaction id, Signature hash). The broadcast goes through the REST API, as it would from any client.
TO=$(lotus-cli -regtest getnewaddress)
RAW=$(lotus-cli -regtest createrawtransaction '[]' "{\"$TO\":10}")
FUNDED=$(lotus-cli -regtest fundrawtransaction $RAW | jq -r .hex)
SIGNED=$(lotus-cli -regtest signrawtransactionwithwallet $FUNDED | jq -r .hex)
curl -s -X POST $API/txs/broadcast \
-H 'content-type: application/json' -d "{\"hex\":\"$SIGNED\"}"
# {"txid":"6478a5132143fae03178edab7fa5f33942181249fe2bb279c7a930ae58bd8045"}async function broadcast(API, hex) {
const r = await fetch(`${API}/txs/broadcast`, {
method: 'POST',
headers: {'content-type': 'application/json'},
body: JSON.stringify({hex}),
});
const body = await r.json();
if (!r.ok) throw new Error(`${body.error}: ${body.message}`);
return body.txid;
}def broadcast(api, hextx):
req = urllib.request.Request(
api + "/txs/broadcast", data=json.dumps({"hex": hextx}).encode(),
headers={"Content-Type": "application/json", "User-Agent": "my-app/1.0"})
with urllib.request.urlopen(req) as r:
return json.load(r)["txid"]A refused transaction answers 400 with error rejected and the reason in message (for example TX decode failed). Sending the same transaction twice answers its txid again.
Related routes:
| Route | Use |
|---|---|
POST /txs/broadcast-checked | The same, with the token burn guard: refuses a transaction that would destroy SLP or ALP tokens. Use it in a wallet that holds tokens |
POST /txs/token-check | What the guard would say, without sending |
POST /txs/decode | Decode a raw transaction |
POST /txs/broadcast-batch | Up to 1,000 transactions, with a node-wide rate limit |
4. Watch it arrive #
Until it is mined, the payment is in the mempool. An address the chain has never seen answers 404 address_not_found on GET /addresses/<address>, even with a payment waiting; add include_unconfirmed=1, or ask POST /scripts/facts, which answers for any address:
curl -s "$API/addresses/$TO?include_unconfirmed=1"
# ... "confirmed_balance_sats":0,"pending_incoming_sats":10000000,"unconfirmed_tx_count":1 ...
lotus-cli -regtest generatetoaddress 1 $ADDR
curl -s "$API/addresses/$TO"
# ... "balance_sats":10000000,"tx_count":1 ...To be told instead of asking, subscribe on the push WebSocket (start the node with -wslisten=127.0.0.1:12650; the public node serves it at wss://givelotus.org/api/v1/ws):
const ws = new WebSocket('wss://givelotus.org/api/v1/ws', 'lotus-push.v1');
ws.onopen = () => ws.send(JSON.stringify({op: 'subscribe', id: 1,
subs: [{type: 'blocks'}, {type: 'address', value: 'lotus_16PSJKoMbdnGyVQyxhuLuZxSuHvqKUy8nv98cXTVm'}]}));
ws.onmessage = m => console.log(JSON.parse(m.data));Subscriptions belong to the connection: reconnect and subscribe again. See Push interfaces.
5. Where to go next #
- A wallet that should not trust one server: the address query with proofs, or the browser node library in a web page.
- An app written for
chronik-client: Chronik and the old explorer API. - Before 21 December 2026: Napoleon for integrators.
