API Authentication: Wallet Signatures and API Keys
Authenticate with the BlockForecast API. Issue, regenerate, and revoke keys via a nonce-bound wallet signature flow. No accounts, no OAuth — your wallet is your identity.
BlockForecast uses a wallet-signature authentication model: you prove ownership of an EVM address by signing a server-issued challenge, and the API returns a long-lived key tied to that address. Every subsequent request passes this key in the X-API-Key header. There is no username/password and no OAuth flow.
Easiest path: sign in at blockforecast.io/settings/api-keys and tap Generate key. Privy pops the wallet signature, the key is shown once, you copy and store it. Use the programmatic flow below only if you’re issuing keys from CI / a server / a script.
Three steps: request a challenge, sign the exact message it returns, post both back. Each nonce is single-use and bound to your wallet + the action (issue, revoke, regenerate), so an intercepted signature can’t be replayed for any other operation.
1
Request a challenge
POST /api/v2/auth/challenge returns a single-use nonce + the exact message your wallet must sign.
The challenge expires in 5 minutes. The message format includes the action and your address so a signature for issue can’t be replayed for revoke or regenerate.
2
Sign the exact message
Use EIP-191 personal sign (personal_sign) with the wallet whose address you sent in step 1. Don’t construct your own message — sign the one the server returned verbatim.
Returns prefixes (not raw keys), labels, rate limit, scopes, created/last-used timestamps. No auth required — a key’s prefix isn’t a secret. Used by the /settings/api-keys page.
Same scopes + rate limit, new key value. Useful when you want to rotate without losing your “key slot” or having to update label references downstream.
# 1. Challenge with action: "regenerate"curl -X POST https://blockforecast.io/api/v2/auth/challenge \ -H "Content-Type: application/json" \ -d '{ "address": "0x...", "action": "regenerate", "keyId": 7 }'# 2. Sign + post — the server atomically revokes the old key and issues a new onecurl -X POST https://blockforecast.io/api/v2/auth/keys/7/regenerate \ -H "Content-Type: application/json" \ -d '{ "address": "0x...", "message": "...", "signature": "0x...", "nonce": "..." }'
The response shape matches POST /auth/token — the new key is shown once.
Never expose bf_… keys in client-side JavaScript, public repos, or build logs. Anyone with the key can trade and read account data on behalf of the wallet that issued it.
Store in your secrets manager (AWS Secrets Manager, Doppler, 1Password, env-file mounted at runtime). Never commit.
Use one key per environment (prod-bot, staging-bot, local-dev) — the label keeps you sane and revoke is single-key, not single-wallet.
Rotate via /keys/:id/regenerate on a schedule or after any suspected exposure. Old key dies the moment the new one is shown.
For server-to-server integrations, give each agent its own dedicated wallet so a leak doesn’t expose your trading wallet’s positions.
In CI / serverless where you can’t interactively sign, generate the key once from a local wallet (or via the /settings/api-keys UI) and inject the resulting bf_… value as a build secret. The key is what production uses; the signing wallet only needs to be online during issuance.