> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://sdk.railnet.org/api/mcp` to find what you need.

# Deploying a multi-vehicle

Bringing up a multi-vehicle is several transactions against several factories, and each step needs
an address the previous one returned. The SDK gives you the builders and the log parsers; the
order is here.

There is no `deployMultiVehicle` function. The sequence is yours to send, so you can report
progress, retry one step, and see which one failed.

## The order

:::steps
##### Read the initial deposit amount

The read itself reverts `AssetNotAuthorized` when the registry has none registered for the asset.
See [`getInitialDepositAmount`](/actions/getInitialDepositAmount).

##### Approve the multi-vehicle factory for that amount

A plain ERC-20 call.

##### Spawn the access control, unless you are reusing one

[`buildSpawnAccessControlCall`](/actions/buildSpawnAccessControlCall). Read its address back out of
the receipt with `extractAccessControlAddress`.

##### Spawn the multi-vehicle

[`buildSpawnMultiVehicleCall`](/actions/buildSpawnMultiVehicleCall). `extractMultiVehicleContracts`
returns the multi-vehicle, its vehicle manager, its queue strategy engine, its sector accounting
engine, its sub query engine and its query redeem queue.

##### Grant the admin roles

[`buildGrantScopedRoleCall`](/actions/buildGrantScopedRoleCall). `MULTI_VEHICLE_SET_QUEUES` goes to
the queue strategy engine, `MULTI_VEHICLE_SET_VEHICLE_AUTHORIZATION` to the vehicle manager, not to
the multi-vehicle. See [Managing roles](/guides/managingRoles) for what a wrong scope does.

##### Authorize each vehicle

[`buildAuthorizeVehicleCall`](/actions/buildAuthorizeVehicleCall) on the vehicle manager.

##### Set the queues

[`buildSetQueuesCall`](/actions/buildSetQueuesCall) on the queue strategy engine, with a deposit and
a redeem target per vehicle.
:::

## Sending each step

Every builder returns `{ address, abi, functionName, args }`. Simulate first so a revert reaches
you with its reason before you pay for it:

```ts
import { simulateContract, waitForTransactionReceipt, writeContract } from 'viem/actions'
import { extractMultiVehicleContracts, buildSpawnMultiVehicleCall } from '@railnetorg/railnet-sdk'

const { request } = await simulateContract(client, {
  ...buildSpawnMultiVehicleCall(params),
  account,
})
const hash = await writeContract(client, request)
const receipt = await waitForTransactionReceipt(client, { hash })

const contracts = extractMultiVehicleContracts(receipt, multiVehicleFactory)
if (!contracts) throw new Error('no multi-vehicle in the logs')
```

Keep every hash. A partial deployment is resumable only from the step that last landed.
