Upload a Contract Manifest to the Registry with the Command Line

You can use the command line to validate and publish deployment metadata from a selected Hardhat project to contract registry services.

The upload-contract-manifest Hardhat task publishes the project’s upgradeable or immutable contract manifests to configured registry services.

Run the task from the packaged contract project’s root directory after a successful deployment. The task reads deployment manifest files from the project. The following files are the standard locations:
  • OpenZeppelin manifest: .openzeppelin/unknown-<chain-id>.json
  • ERC-7201 manifest: .obp-da/.erc7201/deployedContracts-<chain-id>.json
  • Immutable/Solidity manifest: .obp-da/.solc/deployedContracts-<chain-id>.json
Use the chain ID of the target environment in place of <chain-id>. If your OpenZeppelin manifest is stored elsewhere, set the OZ_MANIFEST_PATH variable to its project-local path.
  1. Configure registry endpoints. Set the registry endpoint variables for the manifest types that you plan to upload. Use your shell’s secure environment-variable mechanism or the project’s configured Hardhat variable mechanism; do not commit credentials or private endpoints to source control. For example, a one-time shell invocation can provide the values to the task, as shown in the following example.
    ERC7201_MANIFEST_UPLOAD_REGISTRY_ENDPOINT="https://registry.example/erc7201" \
    SOLC_UPLOAD_REGISTRY_ENDPOINT="https://registry.example/solc" \
    npx hardhat upload-contract-manifest --mode all
    For an Oracle Blockchain Platform environment, also provide the target chain information and the RPC proxy authorization token required by your project configuration.
    BESU_CHAIN_ID="<chain-id>" \
    BESU_RPX_PROXY_AUTH_TOKEN="<rpc-proxy-token>" \
    ERC7201_MANIFEST_UPLOAD_REGISTRY_ENDPOINT="https://registry.example/erc7201" \
    SOLC_UPLOAD_REGISTRY_ENDPOINT="https://registry.example/solc" \
    npx hardhat upload-contract-manifest --mode all
    The endpoint values are explicit configuration. Do not assume that a registry URL can be derived from an Oracle Blockchain Platform host name.
  2. Select what to upload by choosing one of the following modes.
    # Upload both applicable manifest types.
    npx hardhat upload-contract-manifest --mode all
    
    # Upload the OpenZeppelin and ERC-7201 manifest content.
    npx hardhat upload-contract-manifest --mode erc7201
    
    # Upload immutable/Solidity contract manifest content only.
    npx hardhat upload-contract-manifest --mode immutable
    The all and erc7201 modes require the ERC7201_MANIFEST_UPLOAD_REGISTRY_ENDPOINT variable. The all and immutable modes require the SOLC_UPLOAD_REGISTRY_ENDPOINT variable. For packaged imported projects or digital assets contracts generated by Blockchain App Builder, ERC-7201 mode is sufficient.
  3. Use the --dry-run option to validate the selected manifest files and upload configuration without publishing.
    npx hardhat upload-contract-manifest --mode all --dry-run
  4. After a successful dry run, run the same command without the --dry-run option to publish. If your project supports it, set the UPLOAD_CONTRACT_MANIFEST_TIMEOUT_MS variable to increase the upload timeout and set UPLOAD_CONTRACT_MANIFEST_VERBOSE=true for additional diagnostic output. Do not include secrets in verbose logs or shared terminal output.

Troubleshooting

Condition Resolution
Task not found Confirm that the manifest-upload plug-in is installed, imported by the hardhat.config.ts file, and configured with the upload task.
Required manifest is missing Deploy to the selected environment first, confirm the chain ID, and check the expected manifest location. For a nonstandard OpenZeppelin manifest, set the OZ_MANIFEST_PATH variable to the correct project-local file.
Registry endpoint is missing or invalid Provide an http or https endpoint for the mode that you selected. The erc7201 and immutable modes use different endpoint variables.
Oracle Blockchain Platform upload is unauthorized Verify that the selected Oracle Blockchain Platform environment, and BESU_CHAIN_ID and BESU_RPX_PROXY_AUTH_TOKEN variables are all for the same target environment.