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.
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.
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.
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
import { Address, beginCell, Cell, Contract, contractAddress } from '@ton/core';export type CounterConfig = { id: number; counter: number;};export function counterConfigToCell(config: CounterConfig): Cell { return beginCell().storeUint(config.id, 32).storeUint(config.counter, 32).endCell();}export class Counter implements Contract { constructor(readonly address: Address, readonly init?: { code: Cell; data: Cell }) {} static createFromConfig(config: CounterConfig, code: Cell, workchain = 0) { const data = counterConfigToCell(config); const init = { code, data }; return new Counter(contractAddress(workchain, init), init); }}
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)
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:
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: