Learn
Wallet contract
What is wallet

Tact wallet contract

What is wallet

This article explains how wallet contract works in Tact, how to deploy and test this.

💡

Did you notice something unclear, incorrect or get stuck with some issue in this guide? Please ask a question in the Telegram chat (opens in a new tab) or text me directly @iftryalexg (opens in a new tab). Guide will be updated ASAP and all unclear points will be clarified 🚒💦🔥.

Set up your environment

For this project you should install

Tact wallet demo project

Get tact-wallet project from git:

git clone https://github.com/ton-community/tact-wallet
cd tact-wallet

This project has ready to use TACT compiler, typescript + jest with ton-emulator (opens in a new tab), example how to test and deploy. You have ready-to-use commands configured for contract. Try to input them in terminal and look how it works:

yarn test # To test contract
yarn build # To build contract
yarn deploy # To deploy contract via deployment link
yarn deploy-api # To deploy through API(need to input deployment wallet in wallet.deploy-api.ts before using)

Briefing for Tact project structure

In the tact-wallet/sources/ directory placed core project files, that defines what yarn commands will do:

  1. File wallet.tact contract on Tact language, that will be compiled with Tact compiler in yarn build
  2. File wallet.spec.ts contents unit tests for yarn tests command. This command allow to launch local tests on your local IDE. Not necessary for deployment.
  3. File wallet.deploy.ts is a helper, that allow to deploy your wallet.tact compiled file(src/output) with deployment link. From the beginning you can deploy your smart contract via Sandbox (opens in a new tab)/Tonkeeper (opens in a new tab) application.
  4. Describes alternative deployment script wallet.deploy-api.ts for yarn deploy-api according to your contract.tact to send deployment message from deployment wallet. You need to input your deployment wallet 24 words here.

What is wallet contract general idea?

Wallet similar to usual smart contract serve as a platform for managing and transferring funds in a decentralized and secure manner. However, it is important to note that while a smart contract may have built-in features for handling funds, additional steps may be necessary to make the user experience more convenient and secure. This may involve handling additional user stories and implementing additional features to meet real-life requirements.

Let's describe small list of feature for wallet contract:

  • Deployment of smart contract where placed information of its owner with public key.
  • Requests for action with funds by owner.
  • Get and handle messages from other smart-contracts, including incoming transfer of funds.
📚️

Explorers recognize contract's type by hash of the smart contract's code or/and by interfaces founded in smart contract. If you check your common wallet contract with explorer (opens in a new tab)(testnet explorer (opens in a new tab)), you will see that it recognized with type "wallet". From this side, tact-wallet contract is a new version, and it will have different hash(because of original FunC contract and FunC compiled from Tact will be absolutely different). On the same reason current wallet application will not support Tact contract until they add its tact version to their applications.