@stdlib/deploy
Provides unified mechanisms for deployments.
To use this library, import @stdlib/deploy
:
import "@stdlib/deploy";
Messages
Deploy
Message struct used in a receiver of the deprecated Deployable
trait.
message Deploy { /// Unique identifier for tracking transactions across multiple contracts. queryId: Int as uint64;}
DeployOk
Forwarded message struct used in deprecated Deployable
and FactoryDeployable
traits.
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
trait.
message FactoryDeploy { /// Unique identifier for tracking transactions across multiple contracts. queryId: Int as uint64;
/// Address to forward `DeployOk` message to. cashback: Address;}
Traits
Deployable
Deprecated since Tact 1.6The trait Deployable
provides a unified mechanism for deployments by implementing a simple receiver for the 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
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
message and echo the same queryId
in the response.
Source code:
trait Deployable { receive(deploy: Deploy) { self.notify(DeployOk{queryId: deploy.queryId}.toCell()); }}
Usage example:
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.
contract ExampleContract { // Forwards the remaining value in the // incoming message back to the sender receive() { cashback(sender()) }}
FactoryDeployable
Deprecated since Tact 1.6The trait FactoryDeployable
provides a convenient unified mechanism for chained deployments.
Source code:
trait FactoryDeployable { receive(deploy: FactoryDeploy) { self.forward(deploy.cashback, DeployOk{queryId: deploy.queryId}.toCell(), false, null); }}
Usage example:
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.
contract ExampleContract { // Forwards the remaining value in the // incoming message back to the sender receive() { cashback(sender()) }}