---
title: "@stdlib/deploy"
description: "Provides unified mechanisms for deployments"
---

import { Badge } from '@astrojs/starlight/components';

Provides unified mechanisms for deployments.

To use this library, import `@stdlib/deploy`:

```tact
import "@stdlib/deploy";
```

## Messages

### Deploy

Message struct used in a receiver of the **deprecated** [`Deployable{:tact}`](#deployable) trait.

```tact
message Deploy {
    /// Unique identifier for tracking transactions across multiple contracts.
    queryId: Int as uint64;
}
```

### DeployOk

Forwarded message struct used in **deprecated** [`Deployable{:tact}`](#deployable) and [`FactoryDeployable{:tact}`](#factorydeployable) traits.

```tact
message DeployOk {
    /// Unique identifier for tracking transactions across multiple contracts.
    queryId: Int as uint64;
}
```

### FactoryDeploy

Message struct used in a receiver of the **deprecated** [`FactoryDeployable{:tact}`](#factorydeployable) trait.

```tact
message FactoryDeploy {
    /// Unique identifier for tracking transactions across multiple contracts.
    queryId: Int as uint64;

    /// Address to forward `DeployOk` message to.
    cashback: Address;
}
```

## Traits

### Deployable

<Badge text="Deprecated since Tact 1.6" variant="tip" size="medium"/><p/>

The trait `Deployable{:tact}` provides a unified mechanism for deployments by implementing a simple receiver for the [`Deploy{:tact}`](#deploy) message.

All contracts are deployed by sending them a message. While any message can be used for this purpose, you can use the special [`Deploy{:tact}`](#deploy) message.

This message has a single field, `queryId`, provided by the deployer (usually set to zero). If the deployment succeeds, the contract will reply with a [`DeployOk{:tact}`](#deployok) message and echo the same `queryId` in the response.

Source code:

```tact
trait Deployable {
    receive(deploy: Deploy) {
        self.notify(DeployOk { queryId: deploy.queryId }.toCell());
    }
}
```

Usage example:

```tact /Deployable/
import "@stdlib/deploy";

contract ExampleContract with Deployable {
    // Now, this contract has a receiver for the Deploy message
}
```

Unless you need the `queryId`, use a `null` message body receiver instead of this trait.

```tact
contract ExampleContract {
    // Forwards the remaining value in the
    // incoming message back to the sender
    receive() { cashback(sender()) }
}
```

### FactoryDeployable

<Badge text="Deprecated since Tact 1.6" variant="tip" size="medium"/><p/>

The trait `FactoryDeployable{:tact}` provides a convenient unified mechanism for chained deployments.

Source code:

```tact
trait FactoryDeployable {
    receive(deploy: FactoryDeploy) {
        self.forward(deploy.cashback, DeployOk{queryId: deploy.queryId}.toCell(), false, null);
    }
}
```

Usage example:

```tact /FactoryDeployable/
import "@stdlib/deploy";

contract ExampleContract with FactoryDeployable {
    // Now, this contract has a receiver for the FactoryDeploy message
}
```

Unless you need the `queryId`, use a `null` message body receiver instead of this trait.

```tact
contract ExampleContract {
    // Forwards the remaining value in the
    // incoming message back to the sender
    receive() { cashback(sender()) }
}
```

## Sources

* [deploy.tact](https://github.com/tact-lang/tact/blob/61541b7783098e1af669faccd7d2334c10981c72/stdlib/libs/deploy.tact)
