> Starter template for a new TON project - FunC contracts, JS tests, compilation and deployment scripts
## Overview
## Overview
This project is part of a set of 3 typical repositories needed for a blockchain dapp running on TON blockchain:
There are two contracts here:
- Minter contract
* Smart contracts in FunC that are deployed on-chain (this repo)
- Jetton wallet contract that stores jettons for a user
* Web frontend for interacting with the dapp from a web browser (coming soon)
* Telegram bot for interacting with the [dapp from inside Telegram messenger](https://github.com/ton-defi-org/tonstarter-twa)
## What does this repo contain?
## What does this repo contain?
@ -17,50 +13,7 @@ This project is part of a set of 3 typical repositories needed for a blockchain
* `build/_build.ts` - Build script to compile the FunC code to [Fift](https://ton-blockchain.github.io/docs/fiftbase.pdf) and [TVM](https://ton-blockchain.github.io/docs/tvm.pdf) opcodes
* `build/_build.ts` - Build script to compile the FunC code to [Fift](https://ton-blockchain.github.io/docs/fiftbase.pdf) and [TVM](https://ton-blockchain.github.io/docs/tvm.pdf) opcodes
* `build/_deploy.ts` - Deploy script to deploy the compiled code to TON mainnet (or testnet)
* `build/_deploy.ts` - Deploy script to deploy the compiled code to TON mainnet (or testnet)
* `build/_setup.ts` - Setup script to install build dependencies (used primarily for Glitch.com support)
* `build/_setup.ts` - Setup script to install build dependencies (used primarily for Glitch.com support)
* `build/cli.js` - CLI for interacting with the jettons
There is no one official way to develop smart contracts for TON. Every developer has their own best practices. This setup is definitely opinionated and some developers may not appreciate the choices made. Nevertheless, we stand by every choice made here and believe that this is the optimal setup to develop fully tested contracts in the most seamless way possible.
Some of the opinionated choices made here include:
* Cross platform support - allow developers to work on Mac M1, Mac Intel, Windows or Linux
* Strong belief in tests - contracts often manage money - they must be developed under high scrutiny
* Clear and documented code to help users audit the contracts sources and understand what they do
* Reliance on modern TypeScript to develop clean and typed scripts and tests in a modern framework
* Reliance on TypeScript for deployment instead of working with `fift` CLI tools - it's simply easier
* Tests are executed in JavaScript with TVM in web-assembly - a great balance of speed and convenience
* Following of the TON contract [best practices](https://ton.org/docs/#/howto/smart-contract-guidelines) appearing in the official docs
## Dependencies and requirements
To setup your local machine for development, please make sure you have the following:
* A modern version of Node.js (version 16.15.0 or later)
* Installation instructions can be found [here](https://nodejs.org/)
* Run in terminal `node -v` to verify your installation, the project was tested on `v17.3.0`
* The `func` CLI tool (FunC compiler)
* Installation instructions can be found [here](https://github.com/ton-defi-org/ton-binaries)
* Run in terminal `func -V` to verify your installation
* The `fift` CLI tool
* Installation instructions can be found [here](https://github.com/ton-defi-org/ton-binaries)
* Don't forget to set the `FIFTPATH` env variable as part of the installation above
* Run in terminal `fift -V` and `fift` to verify your installation
* A decent IDE with FunC and TypeScript support
* We recommend using [Visual Studio Code](https://code.visualstudio.com/) with the [FunC plugin](https://marketplace.visualstudio.com/items?itemName=tonwhales.func-vscode) installed
Once your local machine is ready, install the project:
* Git clone the repo locally and rename the directory to your own project name
* In the root repo dir, run in terminal `npm install`
### or.. work 100% online instead
Alternatively, you can ignore the above requirements and develop right inside a web browser with an online IDE and *zero* setup. Simply open this repo inside [Glitch](https://glitch.com/) without installing anything:
* Create your new Glitch workspace by opening [this link](https://glitch.com/edit/#!/remix/clone-from-repo?&REPO_URL=https%3A%2F%2Fgithub.com%2Fton-defi-org%2Ftonstarter-contracts.git) in your browser
* Wait about 60 seconds until installation completes <br>(click the "LOGS" button on the bottom of the IDE to see progress)
* Edit your contract files and tests in the online IDE
* To run terminal commands like `npm run build` click the "TERMINAL" button on the bottom of the online IDE
* Working online is slow! run on a local machine if you want a much faster experience