Skip to main content

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

Alternatively you can update the DEBUG environment variable in docker-compose.yml and start the sandbox normally.

environment:
DEBUG: aztec:*