Starter template for a new TON project - FunC contracts, unit tests, compilation and deployment scripts.
This repo is a work in progress and is subject to change
contracts- contains the source code of all the smart contracts of the project and their dependencies.wrappers- contains the wrapper classes (implementingContractfrom ton-core) for the contracts, including any [de]serialization primitives and compilation functions.tests- tests for the contracts. Would typically use the wrappers.scripts- contains scripts used by the project, mainly the deployment scripts.
We ask the community to provide any comments on this layout, the wanted/required changes, or even suggestions for entirely different project structures and/or tool concepts.
PRs are welcome!
- Compiling FunC - https://github.com/ton-community/func-js
- Testing TON smart contracts - https://github.com/ton-community/sandbox/
- Deployment of contracts is supported with TON Connect 2, Tonhub wallet or via a direct
ton://deeplink
- Clone this repo
- Run
yarn install
- Interactively
- Run
yarn blueprint build - Choose the contract you'd like to build
- Run
- Non-interactively
- Run
yarn blueprint build <CONTRACT> - example:
yarn blueprint build pingpong
- Run
- Interactively
- Run
yarn blueprint run - Choose the contract you'd like to deploy
- Choose whether you're deploying on mainnet or testnet
- Choose how to deploy:
- With a TON Connect compatible wallet
- A
ton://deep link / QR code - Tonhub wallet
- Deploy the contract
- Run
- Non-interactively
- Run
yarn blueprint run <CONTRACT> --<NETWORK> --<DEPLOY_METHOD> - example:
yarn blueprint run pingpong --mainnet --tonconnect
- Run
- Run
yarn test
- Run
yarn blueprint create <CONTRACT> - example:
yarn blueprint create Distributor
-
Write code
- FunC contracts are located in
contracts/*.fc- Standalone root contracts are located in
contracts/*.fc - Shared imports (when breaking code to multiple files) are in
contracts/imports/*.fc
- Standalone root contracts are located in
- Tests in TypeScript are located in
test/*.spec.ts - Wrapper classes for interacting with the contract are located in
wrappers/*.ts - Any scripts (including deployers) are located in
scripts/*.ts
- FunC contracts are located in
-
Build
- Builder configs are located in
wrappers/*.compile.ts - In the root repo dir, run in terminal
yarn blueprint build - Compilation errors will appear on screen, if applicable
- Resulting build artifacts include:
build/*.compiled.json- the binary code cell of the compiled contract (for deployment). Saved in a hex format within a json file to support webapp imports
- Builder configs are located in
-
Test
- In the root repo dir, run in terminal
yarn test - Don't forget to build (or rebuild) before running tests
- Tests are running inside Node.js by running TVM in web-assembly using sandbox
- In the root repo dir, run in terminal
-
Deploy
- Run
yarn blueprint run <deployscript> - Contracts will be rebuilt on each execution
- Follow the on-screen instructions of the deploy script
- Run
MIT