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
- Git. Essential tool for every developer to work with repositories. Download it here (opens in a new tab).
- NodeJS. We will use JavaScript with TypeScript mode as the most popular choice for dApp development on TON. Download it here (opens in a new tab).
- JavaScript IDE. Your normal choice for development. VSCode (opens in a new tab), for example.
- Wallet app. You need one of TON noncustodial testnet wallet app (better with support Walletv4), for example Sandbox (opens in a new tab)/Tonkeeper (opens in a new tab). This is as part of simplify demonstration, you also can get access to your wallet from code, example added in demo.
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:
- File
wallet.tact
contract on Tact language, that will be compiled with Tact compiler inyarn build
- File
wallet.spec.ts
contents unit tests foryarn tests
command. This command allow to launch local tests on your local IDE. Not necessary for deployment. - File
wallet.deploy.ts
is a helper, that allow to deploy yourwallet.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. - Describes alternative deployment script
wallet.deploy-api.ts
foryarn deploy-api
according to yourcontract.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.