Migrate a Formance Ledger (v2 API) into Blnk — safely, resumably and verifiably.
formance2blnk is both a CLI and a Go library with zero third-party dependencies.
batch_size postings).USD/2 → currency USD, precision 100, precise_amount).@indicator balances, or skip them; or plug in your own Mapper.It was built to split a combined fiat and crypto Formance ledger in two. A surge in crypto activity could slow the fiat rails, and keeping both asset classes in one ledger widened the regulatory audit scope. The fix was full separation: fiat stays on Formance, and crypto moves with all its history to a standalone Blnk instance. formance2blnk is the pipeline that moves it and proves nothing was lost. See Why formance2blnk for the full story and a carve-out configuration.
📖 The full documentation lives at otyang.github.io/formance2blnk.
# Go toolchain (1.22+)
go install github.com/otyang/formance2blnk/cmd/formance2blnk@latest
# Docker (linux/amd64 and linux/arm64)
docker run --rm ghcr.io/otyang/formance2blnk:latest help
# Library
go get github.com/otyang/formance2blnk@latest
Prebuilt binaries for Linux, macOS and Windows (amd64/arm64) with checksums are attached to every GitHub release.
formance2blnk init > formance2blnk.json # edit URLs, ledgers and mapping
formance2blnk validate # check the config
formance2blnk plan # dry run: what would be created
formance2blnk migrate # run it (Ctrl-C safe, re-runnable)
formance2blnk reconcile -volumes # prove the ledgers match
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/otyang/formance2blnk/blnk"
"github.com/otyang/formance2blnk/formance"
"github.com/otyang/formance2blnk/mapping"
"github.com/otyang/formance2blnk/migrator"
"github.com/otyang/formance2blnk/state"
)
func main() {
ctx := context.Background()
src, _ := formance.New(formance.Options{BaseURL: "http://localhost:3068"})
dst, _ := blnk.New(blnk.Options{BaseURL: "http://localhost:5001", APIKey: os.Getenv("BLNK_API_KEY")})
mapper, _ := mapping.New(mapping.Config{Rules: []mapping.Rule{
{Match: "platform:fees", Indicator: "@Fees"},
{Match: "users:*:wallet", Ledger: "Customer Wallets"},
}})
store, err := state.OpenFile("state.json")
if err != nil {
log.Fatal(err)
}
defer store.Close()
m, _ := migrator.New(src, dst, migrator.Options{Ledgers: []string{"main"}, Mapper: mapper, Store: store})
if _, err := m.Replay(ctx); err != nil {
log.Fatal(err)
}
report, _ := m.Reconcile(ctx, migrator.ReconcileOptions{CheckVolumes: true})
fmt.Println("ledgers match:", report.OK())
}
Try it without any servers: go run ./examples/quickstart.
| Formance | Blnk |
|---|---|
| Ledger | Ledger (by name, or routed by rules) |
| Account × asset | Balance (Blnk balances are single-currency) |
world |
@World indicator balance (configurable) |
Asset USD/2 |
Currency USD, precision 100 |
| Posting | Transaction with precise_amount |
| Multi-posting transaction | Atomic bulk batch |
| Transaction timestamp | effective_date |
| Metadata | meta_data.formance_metadata (+ formance_* provenance keys) |
| Revert | Replayed as a reversal, or both dropped (reverts: skip) |
| Package | Purpose |
|---|---|
migrator |
The engine: replay, snapshot, hybrid, reconcile |
mapping |
Account and asset mapping rules |
formance |
Read-only Formance Ledger v2 client (bearer or OAuth2) |
blnk |
Blnk client (ledgers, balances, bulk transactions) |
state |
Resumable progress store (atomic JSON file with lock) |
config |
JSON config with ${ENV} expansion |
amount |
Big-integer amounts that survive JSON |
internal/httpx |
Shared HTTP client: retries, backoff, rate limiting |
internal/fakes |
In-memory Formance and Blnk fakes for tests and examples |
cmd/formance2blnk |
The CLI |
Built against the Formance Ledger v2 REST API and the Blnk Core API. Both evolve — run plan and a reconciliation against a staging copy first. See Compatibility for the exact endpoints used.
Issues and pull requests are welcome — see CONTRIBUTING.md. Run make check before submitting.
MIT. Not affiliated with Formance or Blnk Finance.