Dependencies
The example pins
ethers@5 intentionally for CommonJS-friendly bot projects. If your service already runs as ESM, you can adapt the signing helpers to ethers@6+, but do not upgrade the sample dependency without also reviewing the module format and API changes.Recommended Client Surface
If you build a small wrapper around the API, use a surface like this:
The examples below assume a wrapper with this shape. You can also call the REST and WebSocket endpoints directly.
Minimal Limit Order Flow
Signing Behavior
The bot client signs the serialized order returned bybuildOrders().
For ECDSA_SECP256K1 accounts:
- Build the EIP-712 order payload.
- Sign with
wallet._signTypedData(domain, types, order). - Prefix the signature with
0x00.
ED25519 Hedera accounts:
- Build the same EIP-712 order payload.
- Hash it with
ethers.utils._TypedDataEncoder.hash. - Sign the raw hash bytes with the Hiero SDK private key.
- Prefix the signature bytes with
0x00.
0x01 signing mode and submit a HIP-632 SignatureMap around the raw wallet signature.
Implementation Notes
- Cache the value returned by
getDomain()for the current session. - Reuse the same authenticated account for build, sign, save, and cancellation.
- Sign the order returned by
buildOrders(), not the original request body. - Preserve all integer fields as strings.
- Use
baseTokenDecimalsandquoteTokenDecimalsfromgetOrderbooks()when converting between display amounts and raw token units. - Keep the signature mode byte in the submitted signature.
- Re-authenticate before reconnecting WebSocket streams.