In practice, contract sources are split into multiple files. A project containing multiple contracts shares the same codebase (messages, storage definitions, and related logic). To use symbols in another file, that file must be imported. Upon import, all its symbols become available.Documentation Index
Fetch the complete documentation index at: https://companyname-a7d5b98e-jeshecdom-fift-variables.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Import a file to access its symbols
For example, error codes are placed inerrors.tolk:
parse.tolk, an explicit import is required:
All top‑level symbols must have unique names
Notice that noexport const ... or export fun ... declarations needed.
All constants, functions, etc. are visible.
No module‑private symbols exist.
It means that all symbols must have unique names.
Having fun log() in multiple files results in a “duplicate declaration” error if both files are imported.
Techniques to avoid name collisions
- Use long, descriptive names for top-level symbols, especially in multi‑contract projects
- Good:
ReturnExcessesBack,WalletStorage - Bad:
Excesses,Storage
- Good:
- Group integer constants to enums
- Prefer methods to global-scope functions (read an idiom)
Symbols that may be repeated across the project
When developing multiple contracts, each contract has its own file (compilation target). They do not import one another; therefore,onInternalMessageandonExternalMessageget fun- and other declarations in a contract file don’t conflict with each other
- its entrypoints,
- probably, a union with allowed messages,
- and little else; the remaining codebase is shared.
SomeMessage, outgoing for contract A, is incoming for contract B.
When deploying one contract from another, a storage struct must be known. And similar.
As a guideline, group messages / errors / utils / etc. in shared files,
and use only minimal declarations inside each contract.tolk.