Skip to main content
Ensure your current directory is the root of the project initialized with npm create ton@latest.

Contract creation

Use Blueprint to create a new contract.

Interactive mode

To launch a guided prompt to create a contract step by step, use:

Non-interactive mode

To create a contract without prompts, provide the contract name and template type:
  • <CONTRACT>- contract name
  • <TYPE>- template type, e.g., tolk-empty, func-empty, tact-empty, tolk-counter, func-counter, tact-counter
Example:

Contract code writing

After creation, contracts are placed in the contracts/ folder. Each file uses the extension that matches its language. For example, creating a Tolk contract MyNewContract results in contracts/my_new_contract.tolk.

Building

Blueprint compiles your contracts into build artifacts.

Interactive mode

Run without arguments to select contracts from a prompt:

Non-interactive mode

Specify a contract name or use flags to skip prompts:
Example:

Compiled artifacts

Compiled outputs are stored in the build/ directory.
  • build/<CONTRACT>.compiled.json- serialized contract representation used for deployment and testing. Each file contains three fields:
    • hash — hash of the compiled contract code in hexadecimal format.
    • hashBase64 — the same hash encoded in Base64.
    • hex — the compiled contract code in hexadecimal form.
    Example:
    <CONTRACT>.compiled.json
  • build/<CONTRACT>/<CONTRACT>.fif — Fift code derived from the contract.

Wrappers

Wrappers are TypeScript classes that you write to interact with your smart contracts. They act as a bridge between your application code and the blockchain, encapsulating contract deployment, message sending, and data retrieval logic. Each wrapper implements the Contract interface from @ton/core. When you create a new contract with Blueprint, you need to write your own wrapper class in the wrappers/ folder to define how your application will interact with the contract.

Static creating methods

Wrappers typically include two main static methods for creating contract instances:

createFromAddress(address: Address)

Creates a wrapper instance for an already deployed contract using its address. This method is used when you want to interact with an existing contract on the blockchain.
./wrappers/Counter.ts

createFromConfig(config, code, workchain)

Creates a wrapper instance for a new contract that hasn’t been deployed yet. This method calculates the contract’s future address based on its initial state and code.
./wrappers/Counter.ts
Parameters:
  • config - Initial configuration data for your contract
  • code - Compiled contract code (usually loaded from build artifacts)
  • workchain - workchain ID (0 for basechain, -1 for masterchain)

Sending messages

Message sending methods allow your application to trigger contract execution by sending internal or external messages. These methods handle the construction of message bodies and transaction parameters. All sending methods follow a similar pattern and should start with send:
./wrappers/Counter.ts
Parameters:
  • provider - ContractProvider instance that handles blockchain communication
  • via - Sender object representing the transaction sender
  • opts - Options object containing transaction value and method-specific parameters

Calling get methods

Get methods allow you to read data from smart contracts without creating transactions. These methods are read-only operations that query the contract’s current state. All get methods should start with get and return a Promise:
./wrappers/Counter.ts

Complete example

./wrappers/Counter.ts

Testing

To test contracts, follow the Smart contract testing.

Deployment

To deploy contracts, follow the Deployment and interaction section.