Skip to content

Deploying z0 Infrastructure

The z0 SDK provides automation to help you manage your Cloudflare infrastructure.

When creating a new ledger, you can use the --remote (or -r) flag to automatically update your wrangler.toml with the necessary Durable Object bindings and migrations.

Terminal window
z0 make:ledger Account --remote
  1. File Creation: src/ledgers/AccountLedger.ts is created from a template.
  2. Binding Added: A new [[durable_objects.bindings]] entry is added to wrangler.toml.
  3. Migration Added: A new [[migrations]] entry with an incremented tag (e.g., v2, v3) is added.

After running the command with the --remote flag, follow these steps:

  1. Export the Ledger: Ensure your new ledger class is exported from your main entry point (e.g., src/index.ts).
  2. Update Manifest: Add the new entity and its ledger to your DomainManifest.
  3. Deploy: Run the following command to push your changes and create the infrastructure on Cloudflare:
    Terminal window
    wrangler deploy

If you prefer to manage your configuration manually, simply omit the --remote flag and add the following blocks to your wrangler.toml:

[[durable_objects.bindings]]
name = "ACCOUNT_LEDGER"
class_name = "AccountLedger"
[[migrations]]
tag = "vX" # Increment based on your current migrations
new_classes = ["AccountLedger"]