Quickstart: TypeScript + WASM
Sign and send your first Lighter order from TypeScript using the official WASM signer from lighter-go. Works in Node.js and the browser.
Lighter transactions are signed with a custom scheme (not EIP-712). The reference signer is written in Go and compiled to WebAssembly, so you can use it from any JavaScript runtime.
By the end of this page you will have one runnable script that verifies your API key, places a limit order on mainnet from Node.js and cancels it. Using Python instead? See Get Started.
Prerequisites
Node.js 22+ and Go 1.23+
A Lighter account (deposit once via app.lighter.xyz or see Deposits, Transfers and Withdrawals)
An API key registered to that account: its private key, API key index (4–254), and your account index. Create one at app.lighter.xyz or programmatically – see Create accounts programmatically.
1. Build the signer
git clone https://github.com/elliottech/lighter-go
cd lighter-go
GOOS=js GOARCH=wasm go build -trimpath -o ./build/lighter-signer.wasm ./wasm/
# Go's JS glue file, from your Go install
SRC="$(go env GOROOT)/lib/wasm/wasm_exec.js"
[ -f "$SRC" ] || SRC="$(go env GOROOT)/misc/wasm/wasm_exec.js"
cp "$SRC" ./build/wasm_exec.js2. Set up the project
3. The script
Save as quickstart.ts. It verifies your API key, places a buy order far below the market (so it won't fill), then cancels it.
Notes on what it does:
Keep the WASM signer off the network.
CreateClientgets an empty URL and every request goes through JSfetch. AvoidCheckClientandnonce = -1(which asks the signer to fetch the nonce itself): both use Go's HTTP stack, which can't reach the network from WASM (you'll seedial tcp: lookup …).Key check: an auth token signed by your key is only accepted if that key is registered for the account. Any non-200 code (e.g.
invalid signature,couldnt find account) means the key, key index or account index is wrong.Integers: prices and sizes are integers scaled by the market's
price_decimals/size_decimalsfromorderBookDetails. See Core concepts.Every function returns an object; if it has an
errorfield, the call failed.check()turns that into an exception.
4. Run it
Expected output:
Reusing the signer in your app
The guides import the loader from a small module. Split it out of the script like this:
Running in the browser
Same code, but load the module with fetch:
Serve the .wasm with Content-Type: application/wasm. Pre-compressing with Brotli/Gzip is recommended. The same rules apply as in Node: pass an empty URL to CreateClient and make HTTP calls with fetch.
Next steps
Signing Transactions – market orders, TP/SL, modify, batch
Market data – stream order books and trades
WASM signer functions – all 20+ functions and their arguments
Looking for a complete TypeScript client state store and WebSocket pipeline? See elliottech/lighter-ts.
Last updated
Was this helpful?