Debugging
On this section you can learn how to debug your Aztec.nr smart contracts and common errors that you may run into.
Logging in Aztec.nr
You can log statements from Aztec.nr contracts that will show ups in the Sandbox.
Import debug_log
Import the debug_log
dependency from Aztec oracles:
use dep::aztec::oracle::debug_log::{ debug_log };
Write log
Write debug_log()
in the appropriate place in your contract.
debug_log("here");
Other methods for logging include:
debug_log_format()
: for logging Field values along arbitrary strings.
debug_log_format("get_2(slot:{0}) =>\n\t0:{1}\n\t1:{2}", [storage_slot, note0_hash, note1_hash]);
debug_log_field()
: for logging Fields.
debug_log_field(my_field);
debug_log_array()
: for logging array types.
debug_log_array(my_array);
Start Sandbox in debug mode
Prepend the command to start the sandbox with DEBUG=aztec:*
to log everything or DEBUG=aztec:simulator:oracle
to only log your debug_log()
statements.
# Using the docker-compose.yml setup
cd ~./aztec && DEBUG=aztec:* docker-compose up
# or if you're using the npm package
DEBUG=aztec:* aztec-sandbox
Alternatively you can update the DEBUG
environment variable in docker-compose.yml and start the sandbox normally.
environment:
DEBUG: aztec:*
📄️ Aztec.nr Errors
This section contains some errors that you may encounter when writing and compiling contracts in Aztec.nr. If you run into an error that is not listed here, please create an issue.
📄️ Aztec Sandbox Errors
This section contains a list of errors you may encounter when using Aztec Sandbox and an explanation of each of them.