> ## Documentation Index
> Fetch the complete documentation index at: https://developers.circle.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Import a contract

> Add an existing smart contract to your library of contracts. It also can be done in the Developer Services Console.



## OpenAPI

````yaml openapi/smart-contract-platform.yaml post /v1/w3s/contracts/import
openapi: 3.0.3
info:
  description: This is the Circle Contracts API documentation.
  title: Circle Contracts
  version: '1.0'
servers:
  - url: https://api.circle.com
security:
  - BearerAuth: []
tags:
  - name: Templates
  - name: View / Update
  - name: Interact
  - name: Deploy / Import
  - name: Event Monitors
paths:
  /v1/w3s/contracts/import:
    post:
      tags:
        - Deploy / Import
      summary: Import a contract
      description: >-
        Add an existing smart contract to your library of contracts. It also can
        be done in the Developer Services Console.
      operationId: importContract
      parameters:
        - $ref: '#/components/parameters/XRequestId'
      requestBody:
        $ref: '#/components/requestBodies/ImportContract'
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImportContractResponse'
          description: Idempotent request. Contract was already imported.
          headers:
            X-Request-Id:
              $ref: '#/components/headers/XRequestId'
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImportContractResponse'
          description: Contract successfully imported.
          headers:
            X-Request-Id:
              $ref: '#/components/headers/XRequestId'
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Error response for the request.
          headers:
            X-Request-Id:
              $ref: '#/components/headers/XRequestId'
      security:
        - BearerAuth: []
components:
  parameters:
    XRequestId:
      name: X-Request-Id
      in: header
      description: >
        Developer-provided identifier for this request, used for tracing
        requests in Wallets API logs and the Developer Console, and when
        communicating with Circle Support.

        **Must be a UUID to appear in logs.** Non-UUID values are accepted by
        the API but are ignored by logging and tracing systems.
      schema:
        $ref: '#/components/schemas/XRequestId'
  requestBodies:
    ImportContract:
      content:
        application/json:
          schema:
            title: ImportContractRequest
            type: object
            required:
              - address
              - blockchain
              - idempotencyKey
              - name
            properties:
              idempotencyKey:
                $ref: '#/components/schemas/IdempotencyKey'
              name:
                $ref: '#/components/schemas/ContractName'
              description:
                $ref: '#/components/schemas/ContractDescription'
              address:
                $ref: '#/components/schemas/ContractAddress'
              blockchain:
                $ref: '#/components/schemas/Blockchain'
              refreshVerification:
                $ref: '#/components/schemas/RefreshVerification'
      description: Import contract request
      required: true
  schemas:
    ImportContractResponse:
      title: ImportContractResponse
      type: object
      required:
        - data
      properties:
        data:
          type: object
          required:
            - contract
          properties:
            contract:
              $ref: '#/components/schemas/Contract'
            warnings:
              $ref: '#/components/schemas/Warnings'
    Error:
      title: Error
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: integer
          description: Code that corresponds to the error.
        message:
          type: string
          description: Message that describes the error.
    XRequestId:
      type: string
      format: uuid
      description: >-
        A unique identifier, which can be helpful for identifying a request when
        communicating with Circle support.
      example: 2adba88e-9d63-44bc-b975-9b6ae3440dde
    IdempotencyKey:
      type: string
      description: >-
        Universally unique identifier (UUID v4) idempotency key. This key is
        utilized to ensure exactly-once execution of mutating requests. To
        create a UUIDv4 go to
        [uuidgenerator.net](https://www.uuidgenerator.net). If the same key is
        reused, it will be treated as the same request and the original response
        will be returned.
      example: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11
      format: uuid
    ContractName:
      type: string
      description: The name for a contract. Must be alphanumeric [a-zA-Z0-9].
      example: First Contract
    ContractDescription:
      type: string
      description: The description for a contract.
      example: My first hello world contract
    ContractAddress:
      type: string
      description: The on-chain address of this contract.
      example: '0x1e124d7384cd34448ea5907bd0052a79355ab5eb'
    Blockchain:
      type: string
      description: >
        The blockchain network that the resource is to be created on or is
        currently on. 

        Required along with `sourceAddress` if you don't provide `walletId`. The
        `blockchain` and `walletId` fields are mutually exclusive.
      enum:
        - ETH
        - ETH-SEPOLIA
        - MATIC
        - MATIC-AMOY
        - ARB
        - ARB-SEPOLIA
        - UNI
        - UNI-SEPOLIA
        - BASE
        - BASE-SEPOLIA
        - OP
        - OP-SEPOLIA
        - AVAX
        - AVAX-FUJI
        - ARC-TESTNET
        - MONAD
        - MONAD-TESTNET
      example: MATIC-AMOY
    RefreshVerification:
      description: >-
        If true, refreshes the contract's ABI and source code from the
        blockchain explorer for contracts that have since been verified
        on-chain.
      type: boolean
      example: true
    Contract:
      type: object
      required:
        - id
        - name
        - contractInputType
        - createDate
        - updateDate
        - archived
        - blockchain
        - status
        - functions
        - events
        - verificationStatus
        - sourceCode
      properties:
        id:
          $ref: '#/components/schemas/Id'
        deployerWalletID:
          $ref: '#/components/schemas/DeployerWalletId'
        deploymentTransactionId:
          $ref: '#/components/schemas/DeploymentTransactionId'
        txHash:
          $ref: '#/components/schemas/TransactionHash'
        abiJson:
          $ref: '#/components/schemas/AbiJson'
        archived:
          $ref: '#/components/schemas/Archived'
        blockchain:
          $ref: '#/components/schemas/Blockchain'
        bytecode:
          $ref: '#/components/schemas/Bytecode'
        contractAddress:
          $ref: '#/components/schemas/ContractAddress'
        contractInputType:
          $ref: '#/components/schemas/ContractInputType'
        deployerAddress:
          $ref: '#/components/schemas/DeployerAddress'
        deployerUserID:
          type: string
          format: uuid
        deploymentErrorReason:
          type: string
        deploymentErrorDetails:
          type: string
        name:
          $ref: '#/components/schemas/ContractName'
        description:
          $ref: '#/components/schemas/ContractDescription'
        status:
          $ref: '#/components/schemas/ContractStatus'
        verificationStatus:
          $ref: '#/components/schemas/VerificationStatus'
        metadataLink:
          $ref: '#/components/schemas/MetadataLink'
        updateDate:
          $ref: '#/components/schemas/UpdateDate'
        createDate:
          $ref: '#/components/schemas/CreateDate'
        sourceCode:
          $ref: '#/components/schemas/SourceCode'
        functions:
          $ref: '#/components/schemas/Functions'
        events:
          $ref: '#/components/schemas/Events'
        implementationContract:
          type: object
          description: Object of the implementation contract.
    Warnings:
      type: array
      description: >-
        A list of warnings generated during the operation. Warnings provide
        informational context about the operation and may require follow-up
        action.
      items:
        $ref: '#/components/schemas/Warning'
    Id:
      type: string
      format: uuid
      description: System-generated unique identifier of the resource.
      example: c4d1da72-111e-4d52-bdbf-2e74a2d803d5
    DeployerWalletId:
      type: string
      format: uuid
      description: The `id` of the Circle Wallet that deployed this contract.
      example: f39e3dbd-84af-4d3d-b5ac-98fbe047ce6a
    DeploymentTransactionId:
      type: string
      format: uuid
      description: The id of the deployment transaction for this contract.
      example: 00ca46f3-c31b-4e3a-92a9-068d4ff26a63
    TransactionHash:
      type: string
      description: Blockchain generated identifier of the transaction.
      example: '0x4a25cc5e661d8504b59c5f38ba93f010e8518966f00e2ceda7955c4b8621357d'
    AbiJson:
      type: string
      description: The contract's ABI in a JSON stringified format.
      example: >-
        [{"inputs": [],"stateMutability": "nonpayable","type":
        "constructor"},...
    Archived:
      description: >-
        The archive state of the contract. If true, the contract will not be
        visible in your dashboard.
      type: boolean
      example: false
    Bytecode:
      type: string
      description: Bytecode of the contract being deployed.
      minLength: 1
      writeOnly: true
      example: 0x60806040523480156200001157600080fd5b50604051806040...
    ContractInputType:
      type: string
      description: The input type for the contract.
      enum:
        - IMPORT
        - BYTECODE
        - TEMPLATE
        - AUTO_IMPORT
    DeployerAddress:
      type: string
      description: The address that created this contract, if deployed.
      example: '0x1bf9ad0cc2ad298c69a2995aa806ee832788218c'
    ContractStatus:
      type: string
      description: The status of the contract.
      enum:
        - PENDING
        - FAILED
        - COMPLETE
    VerificationStatus:
      type: string
      description: The verification status of the contract.
      enum:
        - UNVERIFIED
        - VERIFIED
    MetadataLink:
      type: string
      description: The ipfs metadata link of the contract.
      example: https://ipfs.io/ipfs/Qme7ss3ARVgxv6rXqVPiikMJ8u2NLgmgszg13pYrDKEoiu
    UpdateDate:
      type: string
      format: date-time
      description: Date and time the resource was last updated, in ISO-8601 UTC format.
      example: '2023-01-01T12:04:05Z'
    CreateDate:
      type: string
      format: date-time
      description: Date and time the resource was created, in ISO-8601 UTC format.
      example: '2023-01-01T12:04:05Z'
    SourceCode:
      type: array
      readOnly: true
      items:
        $ref: '#/components/schemas/SolFile'
    Functions:
      type: array
      description: Functions supported by this contract. Parsed from abi_json.
      items:
        $ref: '#/components/schemas/Function'
    Events:
      type: array
      description: Events this contract can emit. Parsed from abi_json.
      items:
        $ref: '#/components/schemas/Event'
    Warning:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: A machine-readable warning code identifying the type of warning.
          example: IMPLEMENTATION_ABI_UNVERIFIED
        message:
          type: string
          description: A human-readable description of the warning.
          example: >-
            Implementation contract ABI is unavailable. Verify the
            implementation contract on the block explorer and re-import before
            creating event monitors.
    SolFile:
      type: object
      description: Source code of a contract from Etherscan.
      required:
        - fileContent
      properties:
        fileName:
          type: string
          description: Name of the file.
          example: openzeppelin-solidity/contracts/math/SafeMath.sol
        fileContent:
          type: string
          description: >-
            Content of the file. If the contract's source code was flattened
            before verification, this may be the entire source code.
          example: |-
            pragma solidity ^0.4.24;

            /**
             * @title SafeMath
             * @dev Math operations with safety checks...
    Function:
      type: object
      required:
        - type
      properties:
        name:
          type: string
          example: approve
        stateMutability:
          type: string
          example: nonpayable
        type:
          type: string
          example: function
        inputs:
          type: array
          items:
            $ref: '#/components/schemas/ParamType'
        outputs:
          type: array
          items:
            $ref: '#/components/schemas/ParamType'
    Event:
      type: object
      required:
        - type
      properties:
        name:
          type: string
          example: Approval
        type:
          type: string
          example: event
        anonymous:
          type: boolean
          example: false
        inputs:
          type: array
          items:
            $ref: '#/components/schemas/ParamType'
    ParamType:
      type: object
      properties:
        components:
          type: array
          items:
            $ref: '#/components/schemas/AnyValue'
        indexed:
          type: boolean
        name:
          type: string
          example: to
        type:
          type: string
          example: address
        flattenedType:
          type: string
    AnyValue:
      description: Can be any value - string, number, boolean, array or object.
  headers:
    XRequestId:
      description: >
        Developer-provided header parameter or Circle-generated universally
        unique identifier (UUID v4). Useful for identifying a specific request
        when communicating with Circle Support.
      schema:
        $ref: '#/components/schemas/XRequestId'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: PREFIX:ID:SECRET
      description: >-
        Circle's API Keys are formatted in the following structure
        "PREFIX:ID:SECRET". All three parts are required to make a successful
        request.

````