diff --git a/docs/docs/dev_docs/contracts/common_errors.md b/docs/docs/dev_docs/contracts/common_errors.md index ce96e27ed09..cefaa8535fb 100644 --- a/docs/docs/dev_docs/contracts/common_errors.md +++ b/docs/docs/dev_docs/contracts/common_errors.md @@ -1,9 +1,53 @@ -# Errors - -List common errors. +# Common Errors There are two kinds of errors: errors in an Aztec.nr contract, and errors spat out by an Aztec Sandbox node! +This section will provide an overview of the errors you might encounter, and how to fix them. + +### Assertion Error + +This error is thrown when a condition is not met. + +This is what the error typically looks like: +``` +Simulation error: Assertion failed: Balance too low 'sum == amount' +``` + +To address the error. find the line in the contract that is throwing the error and investigate why the condition is not met. + +### Unknown Contract Error +This error occurs when you are trying to interact with a smart contract via an Aztec RPC Server that does not have the necessary information to execute a transaction. + +This is what the error typically looks like: +``` +Unknown contract 0x1d206be10b873b78b875259e1a8c39e2212e2f181d2fd0b0407446487deba522: add it to Aztec RPC server by calling server.addContracts(...) +``` + +To execute a transaction, the Aztec RPC Server needs to know the complete address of a contract, portal address (if portal is used) and contract artifacts. + +To address the error, add the contract to the Aztec RPC Server by calling `server.addContracts(...)`. + +### Unknown Complete Address Error +This error occurs when your contract is trying to get a public key via the `get_public_key` oracle call, but the Aztec RPC Server does not have the Complete Address (Complete Address contains the public key). + +This is what the error typically looks like: +``` +Simulation error: Unknown complete address for address 0x0d179a5f9bd4505f7dfb8ca37d64e0bd0cd31b5cb018e252fd647bdf88959b95. Add the information to Aztec RPC server by calling server.registerRecipient(...) or server.registerAccount(...) +``` + +Your contract typically needs a public key when it wants to send a note to a recipient because the public key is used to encrypt notes. + +:::info +Manually adding the recipient to the Aztec RPC Server should not be required in case the recipient contract has already been deployed and the Aztec RPC Server is fully synced. +This is because this information is submitted on-chain when the recipient contract is deployed. +::: + +### Unknown account +This error occurs when your contract is trying to get a secret via the `get_secret` oracle call, but the Aztec RPC Server does not have the secret for the public key. -Maybe even auto-generate error docs, based on error codes in our codebase. +This is what the error typically looks like: +``` +Could not process note because of "Error: Unknown account.". Skipping note... +``` -Make sure descriptions of errors relate to the end user experience. An error like 'SegFault' is useless to a contract developer! \ No newline at end of file +This error might occurr when you register an account only as a recipient and not as an account. +To address the error, register the account by calling `server.registerAccount(...)`. \ No newline at end of file diff --git a/docs/sidebars.js b/docs/sidebars.js index 94ec83570ed..1ec97eda8ea 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -272,6 +272,7 @@ const sidebars = { "dev_docs/contracts/portals/outbox", ], }, + "dev_docs/contracts/common_errors", // { // label: "Resources", // type: "category",