Book
Deployment

Deploy

Tact Deployer is a small library that integrates with TON Verifier (opens in a new tab) that allows you to deploy your contracts safely using your favorite wallet without needing to manage keys or deploy contracts manually. Tact Deployer also automatically verifies your contract's source code and you can be sure that your compiler is not compromised.

Requirements

Your contract MUST have the Deployer trait from the @stdlib/deploy package to be able to use Tact Deployer.

Installation

To add Tact Deployer to your project, just use yarn:

yarn add @tact-lang/deployer

How to use

When you build your smart contracts using Tact, it produces a package (*.pkg) file that has all the required information about the built smart contract. To deploy your smart contract, you need to create a deployer instance, pass your package file to it and provide initial data for your contract.

import * as fs from 'fs';
import * as path from 'path';
import { Address, contractAddress } from "ton";
import { SampleTactContract } from "./output/sample_SampleTactContract";
import { prepareTactDeployment } from "@tact-lang/deployer";
 
// Parameters
let testnet = true;                                 // Flag for testnet or mainnet
let packageName = 'sample_SampleTactContract.pkg';  // Name of your package to deploy
let outputPath = path.resolve(__dirname, 'output'); // Path to output directory
let owner = Address.parse('<put_address_here>');    // Our sample contract has an owner
let init = await SampleTactContract.init(owner);    // Create initial data for our contract
 
// Calculations
let address = contractAddress(0, init);     // Calculate contract address. MUST match with the address in the verifier
let data = init.data.toBoc();               // Create init data
let pkg = fs.readFileSync(                  // Read package file
    path.resolve(outputPath, packageName)
);
 
// Prepare deploy
let link = await prepareTactDeployment({ pkg, data, testnet });
 
// Present a deployment link and contract address
console.log('Address: ' + address.toString({ testOnly: testnet }));
console.log('Deploy link: ' + link);

After following this link you will be able to deploy and verify your smart contract.