GithubHelp home page GithubHelp logo

escrow-contract-ton's Introduction

TON project template (RFC)

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

Layout

  • contracts - contains the source code of all the smart contracts of the project and their dependencies.
  • wrappers - contains the wrapper classes (implementing Contract from 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!

Repo contents / tech stack

  1. Compiling FunC - https://github.com/ton-community/func-js
  2. Testing TON smart contracts - https://github.com/ton-community/sandbox/
  3. Deployment of contracts is supported with TON Connect 2, Tonhub wallet or via a direct ton:// deeplink

How to use

  • Clone this repo
  • Run yarn install

Building a contract

  1. Interactively
    1. Run yarn blueprint build
    2. Choose the contract you'd like to build
  2. Non-interactively
    1. Run yarn blueprint build <CONTRACT>
    2. example: yarn blueprint build pingpong

Deploying a contract

  1. Interactively
    1. Run yarn blueprint run
    2. Choose the contract you'd like to deploy
    3. Choose whether you're deploying on mainnet or testnet
    4. Choose how to deploy:
      1. With a TON Connect compatible wallet
      2. A ton:// deep link / QR code
      3. Tonhub wallet
    5. Deploy the contract
  2. Non-interactively
    1. Run yarn blueprint run <CONTRACT> --<NETWORK> --<DEPLOY_METHOD>
    2. example: yarn blueprint run pingpong --mainnet --tonconnect

Testing

  1. Run yarn test

Adding your own contract

  1. Run yarn blueprint create <CONTRACT>
  2. example: yarn blueprint create MyContract
  • 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
    • 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
  • 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
  • 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
  • Deploy

    • Run yarn blueprint run <deployscript>
    • Contracts will be rebuilt on each execution
    • Follow the on-screen instructions of the deploy script

License

MIT

escrow-contract-ton's People

Contributors

asaidoguz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.