Fireblocks Agent is an open-source on-prem service written in Typescript which is responsible for receiving new messages to sign from Fireblocks, relay these messages to the client's HSM and return the signed result back to Fireblocks.
- Make sure you have nvm on your machine. To check, run
nvmin a terminal. - To installnvm: - On mac runbrew install nvm- Linux, follow these instructions
git clone https://github.com/fireblocks/fireblocks-agent.gitcd fireblocks-agentnvm use- install dependencies
npm i
-
Build and run example customer server docker:
cd examples/servernpm run build:dockernpm run start:docker- Optional: to scale signing across CPU cores, run the example server in cluster mode instead
-
Configure and run Fireblocks agent:
-
Copy
.env.prodand name it.env.{env-name}(e.g..env.test) -
Edit your newly created
.env.{env-name}file with the right configuration -
Build the Fireblocks agent:
npm run build
-
Start the Fireblocks agent with your desired environment:
npm run start --env=env-name
The Fireblocks agent expect a configuration file (for production it's called .env.prod) with several parameters:
MOBILE_GATEWAY_URL- In production this value should behttps://mobile-api.fireblocks.ioCUSTOMER_SERVER_URL- The client's custom server urlCUSTOMER_SERVER_PULL_CADENCE_MS- Cadence of pulling messages statusCUSTOMER_SERVER_AUTHORIZATION- If exists, the Fireblocks agent will send its value on theAuthorizationheader for each request. The client can use it for authorizing the fireblocks agent or keep track on which agent is calling itSSL_CERT_PATH- If exists, a path to a self-signed SSL certificate which will be used to validate the server certificateWEBSOCKET_ENABLED- Message-delivery transport. When enabled (the default, including when the variable is unset) the agent receives messages from Fireblocks over a high-performance WebSocket push stream from the Mobile API Gateway — this is the recommended mode for a strong or horizontally-scaled ("clustered") customer server that can sign many requests in parallel. To fall back to the conservative HTTP long-polling behaviour (better suited to a single-process / lower-throughput customer server), set it to any offalse,0,no, oroff(case-insensitive, surrounding whitespace ignored). Any other value — including blank or unrecognised — keeps WebSocket delivery on, so the kill-switch never fails open.WS_PING_INTERVAL_MS- WebSocket client-side keep-alive ping cadence in milliseconds (default30000). If no pong or traffic arrives within one interval the socket is treated as half-dead and reconnected. Only relevant whenWEBSOCKET_ENABLEDis notfalse.
The Fireblocks Key Link workspace consists of several components (aka actors). Each with its own responsibilities.
- Console - Fireblocks web console. Link
- Mobile App - Fireblocks mobile app.
- Mobile API Gateway - Fireblocks REST API Server. The Fireblocks agent communicates with this server in the registration flow and for receiving new messages.
- Developer API - Fireblocks back office server for workspace setup and configuration.
- Fireblocks Agent - An on-prem service written in Typescript which is responsible for receiving new messages to sign from Fireblocks, relay these messages to the client's HSM and return the signed result back to Fireblocks.
- Customer Server - The client's own server which receives messages to sign from the Fireblocks agent. Sign them via the client's HSM and provide the Fireblocks agent with the signed messages.
- HSM component - The actual HSM implementation. Can be on prem or a cloud based HSM, or a different Key Management System.
The customer server is a component that should be written by the client according to the client's connection to the HSM component. The server is expected to implement the following OpenAPI spec.
In general, it should support signing messages according to ECDSA and EdDSA algorithms and return the status for given messages.
We provide an example of such a server in examples/server with an integration to a software implementation of an HSM called softHSM
The entry point for the server can be found here
This procedure should happen once. Fireblocks will need a validator key to approve new signing keys. This flow is done via the Fireblocks sdk and not via this program.
Each signing key should be first converted into a certificate which should be signed by an active validator key. The signed certificates are then regsitered to Fireblocks via the API or the Console.
Message delivery (WebSocket by default): By default the agent receives messages from Fireblocks over a WebSocket push stream (Mobile API Gateway, path
/msg/ws) instead of HTTP long-polling. Acknowledgements are sent back over the same socket, and tx-sign responses ride the socket too (see the transport note below); proof-of-ownership responses stay on HTTP. Push delivery removes the throughput ceiling of the long-polling model. To revert to HTTP long-polling, setWEBSOCKET_ENABLED=false. The diagrams above depict the HTTP long-poll message-retrieval flow; under the WebSocket default, message retrieval is push-based rather than polled while the rest of the flow (signing and broadcasting responses) is unchanged.
Response transport (only tx-sign goes over the WebSocket): Of the two response types, only
KEY_LINK_TX_SIGN_RESPONSEis broadcast over the socket (falling back to HTTP whenever the socket is not connected). MAG's WS branch routes every framed broadcast tobroadcastMsg— the same downstream as the HTTPkeylink_tx_sign_responseroute — so sending tx-sign over the socket is equivalent.KEY_LINK_PROOF_OF_OWNERSHIP_RESPONSEalways stays on HTTP: its HTTP route dispatches to a different downstream (zServiceMessageSender) that MAG's broadcastMsg-only WS branch cannot reach, so sending it over the socket would mis-route it.
High-performance mode & at-least-once delivery: The WebSocket transport is the high-performance version of the agent — it is built for a strong or clustered customer server that signs requests in parallel, whereas HTTP long-polling is the conservative default for a single-process / lower-throughput customer server. Because the agent forwards pushed requests concurrently and delivery is at-least-once, the same request (identified by its
requestId) may be delivered more than once — for example, when the Mobile API Gateway redelivers after a reconnect. The customer server MUST cache/dedupe byrequestIdand treat a repeatedrequestIdas idempotent, returning the previously computed result instead of signing again. The agent deliberately stays simple (forward + at-least-once) and relies on the customer server as the idempotency boundary; this assumption is what makes the high-performance path safe.




