v1

latestOpenAPI 3.1.02026-07-17373221.0 KB
Private

Replaces an existing contract in the database, addressing issues with misaligned or incorrect contract data. This endpoint provides a generic, maintainable solution and optimizes performance by optionally skipping recompilation and on-chain RPC calls, using data already stored in the database.

post/private/replace-contract

Request body

addressstring address required

The contract address

transactionHashstring

The creation transaction hash

forceCompilationboolean required

If true, recompiles the contract using the provided jsonInput, compilerVersion and compilationTarget

forceRPCRequestboolean required

If true, fetches the contract's information from the RPC

jsonInputobject

Required if forceCompilation is true. The JSON input to use for recompilation

compilerVersionstring

Required if forceCompilation is true. The compiler version to use for recompilation

compilationTargetstring

Required if forceCompilation is true. The compilation target to use for recompilation

customReplaceMethodstring

Specifies the custom database update strategy to use when replacing contract data. Available methods:

  • "replace-creation-information": Updates an existing verified contract's creation bytecode, deployment transaction details (hash, block number, transaction index, deployer), and creation match status while preserving the runtime verification data. This method is useful for correcting incomplete or missing creation data on contracts that were previously verified only against runtime bytecode.
  • "replace-metadata": Updates only the metadata of an existing verified contract.

Example request

{
  "address": "0x00000000219ab540356cBB839Cbe05303d7705Fa",
  "transactionHash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
  "compilerVersion": "0.8.19+commit.7dd6d404",
  "compilationTarget": "project:/contracts/Storage.sol:Storage",
  "customReplaceMethod": "replace-creation-information"
}

Response

The contract has been successfully replaced.

replacedboolean
addressstring
transactionHashstring
rpcFailedFetchingCreationBytecodeboolean

Indicates if the RPC call to fetch the creation bytecode failed