Acton lets you run individual Tolk files as standalone executable scripts through theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ton-blockchain/acton/llms.txt
Use this file to discover all available pages before exploring further.
acton script command. Scripts share the same standard library as tests — you can deploy contracts, send messages, call get methods, and query chain state — but instead of a test harness, scripts define a main() function as their entry point. The same script file runs against a local emulator by default and broadcasts to testnet or mainnet when you pass --net.
Hello World script
The simplest script imports@acton/io for output and defines main():
scripts/hello.tolk
Passing arguments to scripts
main() can accept parameters. Acton reads the ABI for main() and parses CLI arguments against the declared parameter types — one CLI argument per parameter, in order:
scripts/add.tolk
Supported argument types
| Type | CLI format |
|---|---|
int, uint*, coins | Numeric literal, e.g., 42 |
bool | true or false |
string | Plain shell argument or quoted with escapes |
address | User-friendly TON address string |
address? | Address or null |
cell, slice, bitsN | Hex BoC format |
array<T> | "[10 20 30]" or "[10, 20, 30]" |
| nullable types | Value or null |
If a shell argument contains spaces or square brackets, quote it to pass as a single value.
Unsupported types
tuple, map, dict, builder, any_address, structs, aliases, unions, and lisp_list are not currently supported as direct CLI arguments.
Local emulation vs network broadcast
Scripts run in one of two modes:| Aspect | Local mode (default) | Broadcast mode (--net) |
|---|---|---|
| Blockchain | Local TVM emulator | Real TON blockchain |
| Wallets | Generated test wallets | Configured real wallets |
| TON spent | None (emulated) | Real Toncoin |
| Transaction speed | Instant | Real network timing |
| State persistence | Lost after script ends | Permanent on chain |
Wallet access in scripts
Thescripts.wallet() function is the script-side equivalent of testing.treasury() in tests. It returns a wallet struct with an address field:
scripts/deploy.tolk
- Without
--net: creates a local test wallet backed by the emulator treasury (10,000 TON balance). - With
--net: resolves the named wallet fromwallets.tomlorglobal.wallets.toml. - With
--net --tonconnect:promptWallet()returns"tonconnect", andscripts.wallet()connects to an external wallet via TON Connect.
Sending messages with net.send()
Usenet.send() to send messages from a wallet address. The call returns a SendResultList:
scripts/interact.tolk
Waiting for transactions
After sending a message, use the wait helpers onSendResultList:
scripts/deploy.tolk
| Helper | Behavior |
|---|---|
waitForFirstTransaction() | Polls until the first transaction from the result list is confirmed. Returns null on timeout. |
waitForTrace() | Waits for the complete descendant transaction chain. Returns null on timeout. |
Querying blockchain state
Usenet.runGetMethod() to read contract state:
net.runGetMethod() queries the local emulator state. To query real deployed contracts without broadcasting, use --fork-net:
--fork-net fetches and caches account state from the real network for the duration of the script. When the script runs with --net, the broadcast network automatically becomes the default read network — no separate --fork-net is needed.
Complete deploy script example
scripts/deploy.tolk
Manually controlling broadcast mode
For advanced workflows, toggle the broadcast flag at runtime:net.isBroadcasting():
net.enableBroadcast() / net.disableBroadcast() toggle the runtime flag only. They do not load configured wallets after startup — real sends still require launching the script with --net.Script exit codes
Scripts terminate with an exit code equal to theexit_code of the main get method execution. The maximum exit code is 255 (Unix limitation). Any exit code larger than 255 wraps via x % 256.