A "simnet" is an environment where you can interact with your contracts without running a full Stacks chain. When using Clarinet and Clarinet SDK to write tests, you're using a simnet.
Clarigen automatically includes your simnet contracts and accounts.
To get your simnet contracts and accounts, you can import them and use projectFactory to configure your contracts for simnet:
Calling read-only functions
Clarigen provides helper functions to make strongly typed read-only function calls.
In these examples, assume a contract with a validate-number and get-rate function like so:
ro ("read-only")
If you want to receive the full response, including events, you can use ro:
The return type of ro is:
rov ("read-only value")
If you only care about the return value of the contract call, you can use rov:
rovOk and rovErr
For functions that return a response, you can use rovOk and rovErr to assert that the response is either ok or err and return the inner value:
Calling public functions
When making transactions, you provide two arguments:
The function call payload
The sender (string) address
For these examples, assume an increment function that looks like this:
Transaction receipt type
When calling public functions, the return type is:
tx
txOk and txErr
If you want to automatically throw an error and get the inner value of the ok or err type, you can use txOk and txErr:
Filtering events
If you want to get specific events from a receipt, you can use filterEvents from @clarigen/test.
You can combine this with cvToValue from @clarigen/core to easily verify print events: