tradelayer
v1.9.2
Published
NPM package for interacting with TradeLayer orderbook and building Litecoin/Token/Futures transactions.
Downloads
251
Readme
TLNPM
TradeLayer NPM package for:
- node RPC access on Bitcoin or Litecoin
- wallet-aware orderbook interaction
- spot order placement
- futures market discovery
The repo now has a narrow command surface intended for fast setup and for smaller models that need clear entry points.
Start here
Read AGENT.md first if you are operating this repo through an agent.
Quickstart
- Install dependencies.
npm install- Create a local
.envfrom the template and adjust values if needed.
cp .env.example .envThe default TL_BASE_URL points at the public TradeLayer orderbook host used elsewhere in this repo. Override it if you run your own orderbook service locally.
- Bootstrap a node.
Windows BTC:
npm run setup:win:btcWindows LTC:
npm run setup:win:ltcLinux BTC:
npm run setup:linux:btcLinux LTC:
npm run setup:linux:ltc- Pull the loaded node wallet identity into
.env.
npm run wallet:node- Run the repo health check.
npm run doctor- Inspect markets without placing orders.
npm run demo:spot
npm run demo:futures- Place one spot order only with explicit opt-in.
npm run trade:spot -- --place true --action BUY --idForSale 0 --idDesired 5 --price 100 --amount 0.01Commands
npm run doctorChecks repo shape, env, node connectivity, and orderbook HTTP reachability.npm run wallet:create -- LTCTESTGenerates a standalone seed phrase and address. Use this for seed creation only.npm run wallet:nodeReads the currently loaded node wallet, creates a bech32 address if needed, and persistsTL_ADDRESSandTL_PUBKEYinto.env.npm run demo:spotLoads spot markets and a sample spot orderbook and prints a dry-run order payload.npm run trade:spot -- --place true ...Submits a spot order throughApiWrapper.npm run demo:futuresLoads futures markets and prints a dry-run futures order payload.
Environment
Start from .env.example.
Key fields:
TL_BASE_URLTL_PORTTL_NETWORKTL_ALREADY_ONTL_ADDRESSTL_PUBKEYTL_ALLOW_ORDERRPC_HOSTRPC_PORTRPC_USERRPC_PASSRPC_WALLET
JS usage
const { ApiWrapper } = require('tradelayer');
const api = new ApiWrapper(
process.env.TL_BASE_URL || 'ws://172.81.181.19',
Number(process.env.TL_PORT || 3001),
String(process.env.TL_NETWORK || 'LTCTEST').includes('TEST'),
process.env.TL_ALREADY_ON !== 'false',
process.env.TL_ADDRESS,
process.env.TL_PUBKEY,
process.env.TL_NETWORK || 'LTCTEST'
);Notes
quick.js,quickFut.js,apiEx.js,daytrader.js, andmmEx.jsremain in the repo as references, but they are not the primary entry points.client.jsnow reads RPC configuration from.env, so node settings no longer have to be hardcoded in the source.
