> For the complete documentation index, see [llms.txt](https://docs.baas.sh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.baas.sh/baas-cli/advanced/deployment.md).

# Deploy with Forge

Deploy with forge create or a Foundry script, and let BaaS register the result.

`baas deploy` deploys one contract with a key from your Vault, and that's all most projects need. Sometimes you need more: your own wallet and RPC, a deployment script that sets up several contracts and wires them together, verification, custom gas settings, or any other `forge create` or `forge script` option.

That's what `baas deploy create` and `baas deploy script` are for. They run Forge exactly as you ask, with all its options, then register what Forge deployed in your active project.

Before you start, [sign in](/baas-cli/authentication.md), [select a project](/baas-cli/projects.md), and [put your private key in an environment variable](/baas-cli/reference/configuration.md#pass-a-private-key-safely). Run these commands from your Foundry project directory.

## Deploy one contract

```bash
baas deploy create src/Token.sol:MyToken \
  --rpc-url "$RPC_URL" \
  --private-key "$PRIVATE_KEY"
```

Put the contract first, then your Forge options; constructor arguments go last, after `--constructor-args`. Set the RPC URL with `--rpc-url` or `eth_rpc_url` in `foundry.toml`: it's the network BaaS registers on. Your Foundry RPC aliases and `.env` variables work as usual. [Mappings and units](/baas-cli/deploy.md#add-mappings-and-units) work exactly as with `baas deploy`.

## Run a deployment script

```bash
baas deploy script script/Deploy.s.sol \
  --rpc-url "$RPC_URL" \
  --private-key "$PRIVATE_KEY"
```

Pass your usual options, including `--sig` for a custom entry point. Once the script has run, the CLI registers every contract it deployed, including those created by constructors or factories, each with the mapping and unit files beside its own source. Give deployed contracts unique names, that's how they're matched to their files.

## Good to know

* The deployment is real: broadcasting is always on.
* On the BaaS network, gas is free: nothing to configure.
* Registration starts once Forge has finished. If it fails, your contracts are still deployed: the CLI tells you so and asks you not to redeploy. [Register them from the Console](/baas-cli/troubleshooting.md#before-you-deploy-again) instead.

## Next

* [Command reference](/baas-cli/reference.md) for every option.
* [Deploy with a key from your Vault](/baas-cli/deploy.md) when you'd rather not handle a private key on your machine.
