---
title: "POST /private/replace-contract"
method: POST
path: "/private/replace-contract"
tags: ["Private"]
---

# POST /private/replace-contract

`POST /private/replace-contract`

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.

## Request body

- object
  - `chainId` union, required — The chain ID of the contract
    - string
    - number
  - `address` string, address, required — The contract address
  - `transactionHash` string — The creation transaction hash
  - `forceCompilation` boolean, required — If true, recompiles the contract using the provided jsonInput, compilerVersion and compilationTarget
  - `forceRPCRequest` boolean, required — If true, fetches the contract's information from the RPC
  - `jsonInput` object — Required if forceCompilation is true. The JSON input to use for recompilation
  - `compilerVersion` string — Required if forceCompilation is true. The compiler version to use for recompilation
  - `compilationTarget` string — Required if forceCompilation is true. The compilation target to use for recompilation
  - `customReplaceMethod` string — 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.

## Response `200`

The contract has been successfully replaced.

- object
  - `replaced` boolean
  - `address` string
  - `chainId` union
    - string
    - number
  - `transactionHash` string
  - `newStatus` object
    - `creationMatch` string
    - `runtimeMatch` string
  - `rpcFailedFetchingCreationBytecode` boolean — Indicates if the RPC call to fetch the creation bytecode failed

## Other responses

- `400` — Bad Request
- `500` — Internal Server Error

---

[API](https://skmtc.dev/tempoxyz/apis/contract-verification-api.md) · [All operations](https://skmtc.dev/tempoxyz/apis/contract-verification-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/tempoxyz/contract-verification-api/revisions/a76585f33723/schema)
