Simulating & debugging
What this is for
Section titled “What this is for”Watching your contract work: run it block by block on a pretend blockchain, stop at any line, look at every variable, and see what it sends. And, once it’s deployed, looking at the real contract on the chain.
How it works
Section titled “How it works”- Your contract runs in an invented Signum chain inside the browser. Nothing happens on the real network.
- A scenario supplies the transactions that poke it: who sends what, in which block.
- Blocks only exist when you forge them; that is what ⛏ Next block does. Each block delivers the transactions scheduled for it, and the contract runs.
- Breakpoints stop the contract at a line; Step advances one source line.
Open the simulator
Section titled “Open the simulator”Click Simulate in the workflow rail. Pick a scenario from the Scenario list at the top. A project without a scenario offers two ways in: Create the first scenario, or Step through the built-in default, a single activation transaction, which is enough to watch the contract start.
+ New creates another scenario for this contract.
Write a scenario
Section titled “Write a scenario”A scenario is a .scenario.json file:
{ "version": 2, "creator": "555", "accounts": [ { "id": "1001", "balance": "100_0000_0000" } ], "transactions": [ { "block": 1, "sender": "1001", "amount": "2_2500_0000" }, { "block": 2, "sender": "555", "amount": "2500_0000", "messageHex": "0100000000000000" } ]}| Field | Meaning |
|---|---|
creator |
The account that deploys the contract |
accounts |
Accounts and their starting balances, in planck (1 SIGNA = 1_0000_0000) |
transactions |
What reaches the contract: block (from 1), sender, amount |
message |
Optional: a text message |
messageHex |
Optional: a binary message, such as a method code (see below) |
txId |
Optional: a fixed transaction id; random if omitted |
Numbers are written as strings, and _ separators are allowed. The editor checks the
file as you type and won’t simulate a scenario it can’t read; Simulate in the
scenario editor’s toolbar runs it.
messageHex holds the message as numbers of 8 bytes each, least significant byte
first: method code 1 is 0100000000000000, method 2 with the argument 100 is
0200000000000000 followed by 6400000000000000. In tests, asHexMessage([2n, 100n])
builds the same string.
Run and step
Section titled “Run and step”| Control | What it does |
|---|---|
| ▶ Start / Continue | Runs until a breakpoint or until the round is over |
| Step | Advances one source line |
| Step instruction | Advances one AT instruction (in the asm view) |
| ⛏ Next block | Forges the next block and delivers its transactions |
| ⟳ Reset | Starts the scenario over |
The toolbar shows the current block, the status (ready, running, stopped, finished or error), the steps taken and the current line. When a round is over, forge the next block and press ▶ Start again to run it.
Switch between source and asm to follow the contract in SmartC or in the compiled AT assembly.
Breakpoints
Section titled “Breakpoints”Click a line number to set or remove a breakpoint. The Breakpoints panel lists them.
Look inside
Section titled “Look inside”Contract Status on the right has these tabs:
- Variables: every contract variable and its current value. Struct fields appear
as
struct_field. show internals adds the compiler’s helper variables. - Registers: the AT registers A and B.
- Watch: only the variables you pick.
- Emitted: the transactions the contract sent, with recipient and amount.
Ledger Status shows the simulated chain: every account with its balance (including the contract and the fees paid) and every transaction so far. Payments the contract sends arrive with the next block.
The pop-out button opens a live debug dashboard in a separate tab, handy on a second screen.
Inspect a deployed contract
Section titled “Inspect a deployed contract”Once a contract is on the chain, the inspector shows its live state. Create an Inspect Smart Contract(s) project (or add an Inspection watchlist file) and click Add contract: enter its id and pick the network (Mainnet, Testnet, a local testnet, the node your wallet uses, or a custom node).
For each contract the inspector shows:
- Overview: name, description, creator, balance, status (running, stopped, finished, frozen or dead), code hash, creation block and minimum activation;
- Data stack: the raw memory, slot by slot, with every interpretation of a value;
- Maps: the contract’s map entries, by
key1.
A Label Map (.labels.json) gives the raw slots their variable names and formats.
After deploying from the Studio, Inspect on the success message opens the new
contract with labels generated from your source.