canton-network-docs/Wallet GatewayAutomation
Service account automations
Service account automation lets a backend job, CI pipeline, or other service submit ledger
transactions through the Wallet Gateway without a person in the loop. It uses the same dApp
API as interactive dApps (
4. An API key must be generated.
Create an API key for the target network while logged in as the automation owner:
Network:
A typical production network keeps interactive login on
Store the returned
Use the dApp API with API key authentication:
For service accounts, the Wallet Gateway:
See Real-time events.
prepareExecute, txChanged events), but the request is
authenticated with a user-generated API key. When an API key is used, the Wallet Gateway
prepares, signs, and executes the transaction straight through after prepareExecute.
This differs from Automate with the User API,
which drives the User API with a user JWT. Service account automation drives the dApp API
with an API key and runs unattended.
How it fits together
How authentication works:- An operator logs into the Wallet Gateway with the normal user OAuth flow (
auth, typicallyauthorization_code). - The operator creates wallets and generates an API key (
generateApiKeyin the User API, or the User UI). - The automation sends that API key on dApp API requests:
Authorization: ApiKey <key>. - The Wallet Gateway validates the key, scopes the request to the key owner’s stored wallets
and network, and obtains a ledger access token using the network’s
serviceAccountAuthconfiguration (typicallyclient_credentialsOAuth).
- On
prepareExecutewith API key auth, the Wallet Gateway immediately runs prepare → sign → execute when signing returnssigned. - For external custody signers that approve asynchronously, a background Signing worker polls pending transactions and completes them when the provider approves.
- The
userUrlin theprepareExecuteresponse is still returned for API compatibility; automations should rely ontxChangedevents (or polling transaction status) instead of the approval UI.
- Ledger users, parties, and rights still come from your Canton / IDP setup.
- The Wallet Gateway still needs a stored wallet (party) for the API key owner before
prepareExecutecan succeed. - Interactive users still authenticate with
auth; API keys are an additional automation credential, not a replacement for end-user login.
Prerequisites
Complete every item below before callingprepareExecute from automation.
1. A ledger user must exist in the Wallet Gateway.
The API key is tied to the Wallet Gateway user who created it. That user must have completed a
normal login session at least once so wallets and network context exist in the store. The
ledger user ID used for ledger operations comes from the token obtained via serviceAccountAuth,
so configure that OAuth client such that the minted token’s sub (or your IDP mapping) matches
the ledger user that holds rights for the automated party.
2. A wallet (party) must exist with ledger rights.
prepareExecute uses the API key owner’s primary wallet when actAs is omitted. That party
must exist on the Canton participant and grant the ledger user sufficient rights (typically
actAs / readAs) to prepare and submit the commands you automate. Create or sync wallets
through the User API (createWallet,
syncWallets) or the User UI before automation runs. If no primary wallet is stored,
prepareExecute fails with “No primary wallet found”.
3. A signing provider must be configured.
Each wallet records a signingProviderId that selects which driver signs the transaction:
The provider must be installed and configured on the Wallet Gateway host. See
Signing providers.
The signing provider is chosen at wallet creation time. Automation cannot switch providers
per request; it always uses the primary wallet’s configured provider.
- User UI: open API Keys and create a key (copy it immediately, it is shown only once).
- User API: call
generateApiKey({ "name": "my-automation" })and store the returnedapiKeysecurely.
removeApiKey or the
User UI when they are no longer needed.
5. The network must define serviceAccountAuth.
Straight-through execution requires a serviceAccountAuth block on the network, which the Wallet
Gateway uses to obtain ledger tokens when an API key request arrives. It must use the
client_credentials OAuth method. See
Configure the Wallet Gateway.
Wallet Gateway configuration
Network: auth, adminAuth, and serviceAccountAuth
A typical production network keeps interactive login on authorization_code and adds a
dedicated serviceAccountAuth block for automation:
adminAuth is required when the user has no wallets yet and the Wallet Gateway should discover
parties from the ledger on addSession.
Server: signing worker
Participant-only signing does not require external custody configuration.
One-time setup workflow
Perform these steps once per Wallet Gateway user and network you automate (or repeat when wallets change).1
Log in and create a session
The automation owner logs into the User UI or calls User API
addSession with a normal user
OAuth token. This establishes wallets, network context, and the ability to create API keys.2
Ensure a primary wallet exists
List wallets (
listWallets or the User UI). If empty, create a wallet or sync from the ledger,
then set a primary wallet. Verify the primary party via the dApp API:3
Generate an API key
apiKey securely. It cannot be retrieved again.Submitting transactions
prepareExecute (straight-through)
Use the dApp API with API key authentication:
- Validates the API key and resolves the owner’s wallets and network.
- Obtains a ledger token via
serviceAccountAuth. - Prepares the transaction on the ledger.
- Signs with the primary wallet’s signing provider.
- Executes immediately when signing returns
signed. - Returns
{ "userUrl": "…" }(ignore for automation; monitor events instead).
actAs / readAs in the command match parties the API key owner has in the Wallet
Gateway store. When omitted, the primary wallet’s partyId is used.
Participant signing (synchronous)
When the primary wallet usesparticipant signing, the full flow usually completes inside the
prepareExecute call.
External signing (asynchronous)
When the primary wallet uses Fireblocks, Blockdaemon, or DFNS:prepareExecuteprepares the transaction and submits it to the custody provider.- Signing may return
pendinguntil the provider approves the request. - The Signing worker background process polls pending external transactions and calls sign → execute when approval completes.
- Tune
signingWorker.pollIntervalif you need faster completion.
txChanged event with status executed (or handle failed
or prolonged pending).
Monitor with Server-Sent Events
Subscribe to dApp API events for transaction lifecycle updates. Pass the API key as thetoken
query parameter:
End-to-end checklist
Production operations
Treat service account automation as a critical dependency in production.Configuration hardening
- Configure
adminAutheven when wallets are pre-provisioned; recovery flows and manual sync still depend on it. - Configure
serviceAccountAuthwith a dedicated OAuth client scoped for automation ledger access. - Verify every automated wallet uses a signing provider that is configured and monitored in the target environment.
- Rotate API keys and
serviceAccountAuthsecrets on a schedule; revoke compromised keys immediately withremoveApiKey.
Observability
Monitor Wallet Gateway logs for these structured messages:
Subscribe to
txChanged SSE events and alert when status stays pending longer than your
custody SLA, status becomes failed, or prepareExecute returns an error.
Availability
- The Signing worker runs inside the Wallet Gateway process and polls pending external
transactions at
signingWorker.pollInterval(default 5 s). Run at least one Wallet Gateway replica with this process active (enabled on startup by default). - Persist the Wallet Gateway store (PostgreSQL recommended) so wallets, API keys, and pending transactions survive restarts.
Pre-flight validation
Before promoting an automation to production, verify in staging that:listAccounts(dApp API with API key) returns the expected primary party.- A test
prepareExecutereachesexecuted(orpending→executedfor external signers). - Revoked API keys are rejected with HTTP 401.
Security recommendations
- Store API keys and
clientSecretvalues in a secrets manager; never commit them to source control. - Issue one API key per automation or environment so revocation is scoped.
- Use a dedicated OAuth client for
serviceAccountAuth, separate fromadminAuthand end-userauth, when your IDP supports least-privilege clients. - Prefer external custody signers over
wallet-kernelinternal signing in production. See Signing providers.
Troubleshooting
See also Troubleshooting for ledger
connectivity,
addSession errors, and auth debugging.