Getting started
Deploying your contract

Deploy your contract

Template project provides a handy way to deploy contracts, but you can do it yourself as well.

Deploying with typescript and deploy link

To deploy a smart contract in TON you need to send a message with init data attached to it. The easiest way to get an init for your contract is using a generated typescript bindings that would help to call an init function.

import base64url from 'base64url';
import qs from 'qs';
import { Address, beginCell, storeStateInit, contractAddress, toNano } from 'ton-core';
import { Counter } from './output/sample_Counter';
 
// Forming an init package
let owner = Address.parse("some-address");
let init = await Counter.init(owner);
let testnet = true;
 
// Contract address
let address = contractAddress(0, init);
 
// Amount of TONs to attach to a deploy message
let deployAmount = toNano("0.5");
 
// Create string representation of an init package
let initStr = base64url(
  beginCell().store(storeStateInit(init)).endCell().toBoc({ idx: false })
);
 
// Create a deploy link
console.log(
  `ton://transfer/` +
    address.toString({ testOnly: testnet }) +
    "?" +
    qs.stringify({
      text: "Deploy",
      amount: deployAmount.toString(10),
      init: initStr,
    })
);

After running this code you will get a link that you can open in your favorite TON wallet. It will open a transfer page with a deploy message already filled in. You can change the amount of TONs to attach to a deploy message and click on the Send button. After a few seconds your contract will be deployed and you will see a transaction in your wallet.