Contract Lifecycle

This guide covers the complete lifecycle of a smart contract on TetraChain: from development to deployment and interaction.

Prerequisites

Complete Setting Up Your Environment before proceeding.

Overview

The contract development cycle consists of five stages:

  1. Development — Write contract code in FunC

  2. Build — Compile to TVM bytecode

  3. Test — Validate behavior in sandbox

  4. Deploy — Publish to TetraChain network

  5. Interact — Execute contract methods

1. Development

Create a Contract

Generate a new contract using Blueprint:

npx blueprint create SimpleCounter

Select contract type:

  • Empty contract — Minimal template

  • Counter — Simple state management example

For this guide, select "Counter" — it provides a working example with state management that we'll use throughout the tutorial.

Contract Structure

Blueprint generates three files:

2. Build

Compile Contract

Output:

Build Artifacts

Compiled files are stored in build/:

3. Test

Configure Test Environment for TetraChain

tests/SimpleCounter.spec.ts:

Run Tests

Output:

4. Deploy

Create Deployment Script

scripts/deploySimpleCounter.ts:

Execute Deployment

Blueprint will prompt you to:

  1. Select a script: Choose deploySimpleCounter

  2. Choose a wallet: Select your deployment wallet

5. Interact

Create Interaction Script

scripts/increaseCounter.ts:

Execute Interaction

Output:

For all details about the Contract Lifecycle, please use the links below

Last updated