> For the complete documentation index, see [llms.txt](/llms.txt)

# Contract Artifacts

Compiling an Aztec contract produces a contract artifact file (`.json`) containing everything needed to interact with that contract: its name, functions, their interfaces, and compiled bytecode. Since private function bytecode is never published to the network, you need this artifact file to call private functions.

Most developers don't need this

When you [compile a contract](/developers/docs/aztec-nr/compiling_contracts.md) and use [`aztec codegen`](/developers/docs/aztec-js/how_to_deploy_contract.md#generate-typescript-bindings), you get type-safe TypeScript classes that handle artifacts automatically. This page is useful if you're:

* Building custom tooling around Aztec contracts
* Debugging compilation or deployment issues
* Understanding what data is available in artifacts

## Where to Find Artifacts

After running `aztec compile`, artifacts are output to the `target/` directory:

```text
target/
└── my_contract-MyContract.json    # Contract artifact
```

Use `aztec codegen` to generate TypeScript bindings from these artifacts for type-safe contract interaction.

## Contract Artifact Structure

A contract artifact contains:

* **`name`**: The contract name as defined in Noir
* **`functions`**: Array of function artifacts (private, public dispatch, and utility functions)
* **`nonDispatchPublicFunctions`**: Public function ABIs (excluding the dispatch function)
* **`outputs`**: Exported structs and globals from the contract
* **`storageLayout`**: Storage slot mappings for contract state
* **`fileMap`**: Source file mappings for debugging

## Exported globals

Add `#[abi(tag)]` to a public Noir global to export its name and value in the contract artifact. A tag groups related globals, and you can apply the same tag to multiple globals:

```noir
use aztec::macros::aztec;

#[aztec]
pub contract Globals {
    #[abi(constants)]
    pub global EXPORTED_FIELD_CONSTANT: Field = 1234;
    #[abi(constants)]
    pub global EXPORTED_STRING_CONSTANT: str<8> = "exported";
    #[abi(limits)]
    pub global EXPORTED_LIMIT_CONSTANT: u32 = 100;
    #[abi(constants)]
    #[abi(limits)]
    pub global EXPORTED_SHARED_CONSTANT: u32 = 7;
}
```

The example creates two groups under `outputs.globals`: `constants` and `limits`. Each group is an array of `{ name, value }` entries. Stacking attributes on `EXPORTED_SHARED_CONSTANT` exports the same global under both tags.

When working directly with an artifact, use `getGlobalsByTag` to return the named entries for one tag as raw `AbiValue` objects:

```typescript
import { getGlobalsByTag } from '@aztec-labs/aztec.js/abi';

const constants = getGlobalsByTag(GlobalsContract.artifact, 'constants');
const exportedString = constants.EXPORTED_STRING_CONSTANT;
// { kind: 'string', value: 'exported' }
```

## Function Properties

Each function in the artifact includes:

| Property          | Description                                                                                                                   |
| ----------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `name`            | Function name as defined in Noir                                                                                              |
| `functionType`    | One of `private`, `public`, or `utility`                                                                                      |
| `isOnlySelf`      | If `true`, function can only be called from within the same contract                                                          |
| `isStatic`        | If `true`, function cannot alter state                                                                                        |
| `isInitializer`   | If `true`, function can be used as a constructor                                                                              |
| `parameters`      | Array of input parameters with name, type, and visibility                                                                     |
| `returnType`      | The type the function returns, omitted when it returns nothing. Multiple return values are expressed as a single `tuple` type |
| `errorTypes`      | Custom error types the function can throw                                                                                     |
| `bytecode`        | Compiled ACIR bytecode (base64 encoded)                                                                                       |
| `verificationKey` | Verification key for private functions (optional)                                                                             |
| `debugSymbols`    | Compressed debug information linking to source code                                                                           |

### Function Types

* **`private`**: Executed and proved locally by the client. Bytecode is not published to the network.
* **`public`**: Executed and proved by the sequencer. Bytecode is published to the network.
* **`utility`**: Executed locally to compute information (e.g., view functions). Cannot be called in transactions.

## Parameter and Return Types

Parameters and return values use these type definitions:

| Type      | Description                                                       |
| --------- | ----------------------------------------------------------------- |
| `field`   | A field element in the BN254 curve's scalar field                 |
| `boolean` | True/false value                                                  |
| `integer` | Whole number with `sign` (`signed`/`unsigned`) and `width` (bits) |
| `array`   | Collection of elements with `length` and element `type`           |
| `string`  | Character sequence with fixed `length`                            |
| `struct`  | Composite type with named `fields` and a `path` identifier        |
| `tuple`   | Unnamed composite type with ordered `fields`                      |

Parameter visibility can be `public`, `private`, or `databus`.

## Next Steps

* [Compile contracts](/developers/docs/aztec-nr/compiling_contracts.md) to generate artifacts
* [Deploy contracts](/developers/docs/aztec-js/how_to_deploy_contract.md) using generated TypeScript bindings
* [Send transactions](/developers/docs/aztec-js/how_to_send_transaction.md) to interact with deployed contracts
