Skip to main content

Startup, readiness and file transfers

start(), step by step​

  1. Prepare (no Docker): validate all options, register file copies, set the command and port.
  2. Start the runtime (startRuntime(); Docker by default).
  3. Wait for JSON-RPC, probed every 10 ms, whatever the log settings. If anvil exits, AnvilStartupError reports its output at once.
  4. Initialise: chain id, --config-out, test client, default account.

--host is always 0.0.0.0; the container port (withPort()) is mapped to a host port (getMappedPort()).

Files​

File options take host paths (relative to the working directory):

FlagDirectionWhen
--load-state, --inithost → containerbefore start; the file must exist
--statehost → container, container → hostbefore start if it exists; after stop
--dump-statecontainer → hostafter stop
--config-outcontainer → hostright after start

Files land at CONTAINER_FILE_PATHS; containerPath("/abs") passes files in your image through uncopied.

Graceful stop​

anvil writes dumps on exit. With a dump target, stop() sends SIGTERM, waits up to 30 s (DEFAULT_GRACEFUL_STOP_TIMEOUT_MS), copies the file out, then removes the container.

Related: Save and load chain state, Manage the lifecycle.