Contract Artifacts
The JSON files produced by the Solidity compiler, containing the ABI and bytecode of a smart contract.
Contract artifacts are the primary output of the smart contract compilation process. They are JSON files that serve as the canonical, machine-readable representation of a contract, most notably containing its Application Binary Interface (ABI) and EVM bytecode. In the Maroo ecosystem, these artifacts are critical for enabling interaction between Go modules and the EVM.
Structure of an Artifact
A typical contract artifact generated by Hardhat includes several key fields:
abi: An array of objects defining the contract's public functions, events, and errors. This is the most frequently used part of the artifact, as it dictates how to encode and decode calls to the contract.bytecode: The compiled EVM bytecode as a hex string. This is the code that is actually deployed to the blockchain and executed by the EVM.contractName: The name of the contract.sourceName: The path to the source Solidity file.deployedBytecode: The bytecode of the contract as it exists on-chain, which excludes the constructor logic.
Co-location Strategy
Maroo's build system intentionally places the compiled artifact JSON file directly alongside its source
.sol file. For example, if a contract is defined in precompiles/identity/IIdentity.sol, its artifact will be saved as precompiles/identity/abi.json or precompiles/identity/IIdentity.json. This co-location strategy simplifies dependency management for the core Go modules. A Go module can reliably find the ABI it needs by looking in its own directory, eliminating the need for complex lookup paths or centralized ABI registries.The `abi.json` Convention
For precompile interfaces, the artifact is often named
abi.json instead of ContractName.json. This convention provides a stable, predictable filename for Go code to read. The Go implementation of a precompile can be hardcoded to load abi.json from its module directory, regardless of the specific name of the Solidity interface, making the system more robust to interface renames.Version Control
Contract artifacts are committed to the version control system (Git). This is a deliberate choice to ensure that the Go code and the contract interfaces it depends on are always in sync. When a developer checks out a specific version of the Maroo codebase, they get the exact ABI that the Go code was built and tested against, preventing integration issues caused by ABI mismatches.