Skip to content
Deploy Contract

Deploy Contract

Simple Summary

An RPC method for allowing users to deploy a new smart contract to TON network. ton_deployContract RPC method allow to do it.

This use case apllied in a few different ways. DApp developers may offer to wallet owners to deploy their personal contracts. It's a useful feature allowing owners to store and get information in the contract. Or it can be an option to deploy an NFT contract to reward users after completing a tutorial or course.

Deploy Parameters

interface DeployParams {
    // Smart contract code hexadecimal string
    initCodeCell: string;
    // Smart contract initial data hexadecimal string
    initDataCell: string;
    // Initial mesasge hexadecimal string (optional)
    initMessageCell?: string;
    // Amount to funding smart contract in nanotons, to pay network and storage fee
    amount: string;


Please read more about the example in the blog post. You may find information how to build contract code initCodeCell and generate initDataCell or initMessageCell.

import { useState } from "react";
import { beginCell, Address } from "@openproduct/web-sdk";

const initCode =

const getInitData = async (ownerAddress, counter) => {
  return await beginCell()
    .storeAddress(new Address(ownerAddress))
    .storeUint(counter, 64) // 64 - mean the counter value take 64 bits in a cell - int64 type

const getInitMessage = async () => {
  return await beginCell()
    .storeUint(0x37491f2f, 32)
    .storeUint(0, 64)

export default () => {
  const [disabled, setDisabled] = useState(false);
  const [isSent, setSent] = useState(false);
  const [isConfirm, setConfirm] = useState(false);
  const [address, setAddress] = useState("");

  const send = async () => {
    const provider = window.ton;

    try {
      const [ownerAddress] = await provider.send("ton_requestAccounts");

      const { walletSeqNo, newContractAddress } = await provider.send(
            initCodeCell: initCode,
            initDataCell: await getInitData(ownerAddress, 7),
            initMessageCell: await getInitMessage(),
            amount: "50000000", // 0.05 TON
      await provider.send("ton_confirmWalletSeqNo", [walletSeqNo, ownerAddress]);

    } catch (e) {
    } finally {

  return (
      <button disabled={disabled} onClick={send}>
        Deploy Smart Contract
      {isSent && (
            ? "Done. New contract address: " + address
            : "Deploy Pending... ~15 sec"}


For the counter the correct value is 8. The initial value is 7 and the initial transaction is increment with increment 7 and stored to contract cell.

For the contract owner it has to be your user-friendly bounceable wallet address.