> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://www.openfort.io/api/mcp` to find what you need.
>
> **Have feedback?** Use `submit_feedback` on the same MCP server.

# Contracts

Register smart contracts so transactions and policies can reference them by id.

## List contracts

`GET /v1/contracts`

List of all contracts per project.
By default, a maximum of ten contracts are shown.

### Query parameters

- `limit` `integer <int32>`: Maximum number of records to return per page. Defaults to 10.
- `skip` `integer <int32>`: Number of records to skip before the first one returned. Defaults to 0. Combine with `limit` to page through results.
- `order` `string`: Sort direction by creation date: `asc` (oldest first) or `desc`. Defaults to `desc` (newest first).
- `name` `string`: Specifies the name of the contract.
- `deleted` `boolean`: Specifies whether to include deleted contracts.
- `chainId` `integer <int32>`: The chain ID of the contract.
- `address` `string`: Specifies the address of the contract.

### Responses

#### `200`: A page of contracts.

Body (`application/json`):

- `object` `string` _(required)_: The type of object. Always `list`.
- `url` `string` _(required)_: Path of the endpoint that produced this page.
- `data` `object[]` _(required)_: The items on this page.
  - `id` `string` _(required)_: Unique identifier of the object. The prefix tells its type, for example `acc_` for accounts.
  - `object` `string` _(required)_: The type of object.
  - `createdAt` `integer <int32>` _(required)_: When the object was created, as Unix epoch seconds.
  - `name` `string | null` _(required)_: Display name of the contract, or `null` when none was given.
  - `chainId` `integer <int32>` _(required)_: The chain ID the contract is deployed on.
  - `address` `string` _(required)_: The contract address.
  - `deleted` `boolean` _(required)_: Whether the contract has been deleted. Deleted contracts stay readable so existing references keep resolving.
  - `abi` `object[]` _(required)_: The contract ABI, as supplied in the request or fetched from the block explorer.
    - `name` `string`: Name of the function, event or error. Absent for constructors, fallback and receive.
    - `type` `string`: Kind of entry: `function`, `constructor`, `event`, `error`, `fallback` or `receive`.
    - `anonymous` `boolean`: For events, whether the event is anonymous (its signature is not stored as a topic).
    - `payable` `boolean`: Legacy flag: whether the function accepts native value. Superseded by `stateMutability`.
    - `constant` `boolean`: Legacy flag: whether the function does not modify state. Superseded by `stateMutability`.
    - `stateMutability` `string`: How the function interacts with state: `pure`, `view`, `nonpayable` or `payable`.
    - `gas` `string`: Gas hint emitted by some compilers, as a decimal string.
    - `inputs` `object[]`: Parameters of the function or event.
      - `name` `string`: Parameter name. Empty for unnamed return values.
      - `type` `string`: Solidity type, for example `address`, `uint256` or `tuple`.
      - `indexed` `boolean`: For event parameters, whether the value is indexed (stored as a topic).
      - `internalType` `unknown`: The type as written in the source, for example a struct or contract name.
      - `components` `object[]`: For `tuple` types, the fields of the struct.
    - `outputs` `object[]`: Return values of the function.
      - `name` `string`: Parameter name. Empty for unnamed return values.
      - `type` `string`: Solidity type, for example `address`, `uint256` or `tuple`.
      - `indexed` `boolean`: For event parameters, whether the value is indexed (stored as a topic).
      - `internalType` `unknown`: The type as written in the source, for example a struct or contract name.
      - `components` `object[]`: For `tuple` types, the fields of the struct.
  - `publicVerification` `boolean` _(required)_: Whether the ABI came from the block explorer's public verification rather than from the request.
- `start` `integer <int32>` _(required)_: Zero-based offset of the first item on this page (the `skip` you passed, default 0).
- `end` `integer <int32>` _(required)_: Offset just past the last item on this page (`start` plus the page size).
- `total` `integer <int32>` _(required)_: Total number of items matching the query across all pages.

#### `401`: Missing or invalid credentials.

### Example request

```bash
curl 'https://api.openfort.io/v1/contracts?limit=10&skip=0&order=desc&name=NFT Contract&deleted=false&chainId=80002&address=0x742e6e61d760164d56f44801054bcf40fa821d97'
```

```ts
fetch('https://api.openfort.io/v1/contracts?limit=10&skip=0&order=desc&name=NFT Contract&deleted=false&chainId=80002&address=0x742e6e61d760164d56f44801054bcf40fa821d97')
```

## Create contract object

`POST /v1/contracts`

Add a new contract to your project in Openfort

### Request body (required) (`application/json`)

- `name` `string` _(required)_: Specifies the name of the contract (Only for display purposes).
- `chainId` `integer <int32>` _(required)_: Specifies the chain ID of the contract. Must be a [supported chain](https://www.openfort.io/docs/configuration/chains).
- `address` `string` _(required)_: Specifies the address of the contract.
- `abi` `object[]`: Specifies the ABI of the contract.
  - `name` `string`: Name of the function, event or error. Absent for constructors, fallback and receive.
  - `type` `string`: Kind of entry: `function`, `constructor`, `event`, `error`, `fallback` or `receive`.
  - `anonymous` `boolean`: For events, whether the event is anonymous (its signature is not stored as a topic).
  - `payable` `boolean`: Legacy flag: whether the function accepts native value. Superseded by `stateMutability`.
  - `constant` `boolean`: Legacy flag: whether the function does not modify state. Superseded by `stateMutability`.
  - `stateMutability` `string`: How the function interacts with state: `pure`, `view`, `nonpayable` or `payable`.
  - `gas` `string`: Gas hint emitted by some compilers, as a decimal string.
  - `inputs` `object[]`: Parameters of the function or event.
    - `name` `string`: Parameter name. Empty for unnamed return values.
    - `type` `string`: Solidity type, for example `address`, `uint256` or `tuple`.
    - `indexed` `boolean`: For event parameters, whether the value is indexed (stored as a topic).
    - `internalType` `unknown`: The type as written in the source, for example a struct or contract name.
    - `components` `object[]`: For `tuple` types, the fields of the struct.
  - `outputs` `object[]`: Return values of the function.
    - `name` `string`: Parameter name. Empty for unnamed return values.
    - `type` `string`: Solidity type, for example `address`, `uint256` or `tuple`.
    - `indexed` `boolean`: For event parameters, whether the value is indexed (stored as a topic).
    - `internalType` `unknown`: The type as written in the source, for example a struct or contract name.
    - `components` `object[]`: For `tuple` types, the fields of the struct.
- `publicVerification` `boolean`: Specifies whether to verify the contract publicly.

### Responses

#### `200`: The created contract.

Body (`application/json`):

- `id` `string` _(required)_: Unique identifier of the object. The prefix tells its type, for example `acc_` for accounts.
- `object` `string` _(required)_: The type of object.
- `createdAt` `integer <int32>` _(required)_: When the object was created, as Unix epoch seconds.
- `name` `string | null` _(required)_: Display name of the contract, or `null` when none was given.
- `chainId` `integer <int32>` _(required)_: The chain ID the contract is deployed on.
- `address` `string` _(required)_: The contract address.
- `deleted` `boolean` _(required)_: Whether the contract has been deleted. Deleted contracts stay readable so existing references keep resolving.
- `abi` `object[]` _(required)_: The contract ABI, as supplied in the request or fetched from the block explorer.
  - `name` `string`: Name of the function, event or error. Absent for constructors, fallback and receive.
  - `type` `string`: Kind of entry: `function`, `constructor`, `event`, `error`, `fallback` or `receive`.
  - `anonymous` `boolean`: For events, whether the event is anonymous (its signature is not stored as a topic).
  - `payable` `boolean`: Legacy flag: whether the function accepts native value. Superseded by `stateMutability`.
  - `constant` `boolean`: Legacy flag: whether the function does not modify state. Superseded by `stateMutability`.
  - `stateMutability` `string`: How the function interacts with state: `pure`, `view`, `nonpayable` or `payable`.
  - `gas` `string`: Gas hint emitted by some compilers, as a decimal string.
  - `inputs` `object[]`: Parameters of the function or event.
    - `name` `string`: Parameter name. Empty for unnamed return values.
    - `type` `string`: Solidity type, for example `address`, `uint256` or `tuple`.
    - `indexed` `boolean`: For event parameters, whether the value is indexed (stored as a topic).
    - `internalType` `unknown`: The type as written in the source, for example a struct or contract name.
    - `components` `object[]`: For `tuple` types, the fields of the struct.
  - `outputs` `object[]`: Return values of the function.
    - `name` `string`: Parameter name. Empty for unnamed return values.
    - `type` `string`: Solidity type, for example `address`, `uint256` or `tuple`.
    - `indexed` `boolean`: For event parameters, whether the value is indexed (stored as a topic).
    - `internalType` `unknown`: The type as written in the source, for example a struct or contract name.
    - `components` `object[]`: For `tuple` types, the fields of the struct.
- `publicVerification` `boolean` _(required)_: Whether the ABI came from the block explorer's public verification rather than from the request.

#### `401`: Missing or invalid credentials.

#### `409`: The request conflicts with the current state of the resource.

### Example request

```bash
curl https://api.openfort.io/v1/contracts \
  --request POST \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "NFT Contract",
  "chainId": 80002,
  "address": "0x742e6e61d760164d56f44801054bcf40fa821d97",
  "abi": [
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "_owner",
          "type": "address"
        }
      ],
      "stateMutability": "nonpayable",
      "type": "constructor"
    },
    {
      "inputs": [],
      "name": "owner",
      "outputs": [
        {
          "internalType": "address",
          "name": "",
          "type": "address"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    }
  ],
  "publicVerification": false
}'
```

```ts
fetch('https://api.openfort.io/v1/contracts', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'NFT Contract',
    chainId: 80002,
    address: '0x742e6e61d760164d56f44801054bcf40fa821d97',
    abi: [
      {
        inputs: [
          {
            internalType: 'address',
            name: '_owner',
            type: 'address'
          }
        ],
        stateMutability: 'nonpayable',
        type: 'constructor'
      },
      {
        inputs: [],
        name: 'owner',
        outputs: [
          {
            internalType: 'address',
            name: '',
            type: 'address'
          }
        ],
        stateMutability: 'view',
        type: 'function'
      }
    ],
    publicVerification: false
  })
})
```

## Get a contract

`GET /v1/contracts/{id}`

Retrieve a contract by providing their contract id.

### Path parameters

- `id` `string` _(required)_: Specifies the unique contract ID (starts with con_).

### Responses

#### `200`: The contract.

Body (`application/json`):

- `id` `string` _(required)_: Unique identifier of the object. The prefix tells its type, for example `acc_` for accounts.
- `object` `string` _(required)_: The type of object.
- `createdAt` `integer <int32>` _(required)_: When the object was created, as Unix epoch seconds.
- `name` `string | null` _(required)_: Display name of the contract, or `null` when none was given.
- `chainId` `integer <int32>` _(required)_: The chain ID the contract is deployed on.
- `address` `string` _(required)_: The contract address.
- `deleted` `boolean` _(required)_: Whether the contract has been deleted. Deleted contracts stay readable so existing references keep resolving.
- `abi` `object[]` _(required)_: The contract ABI, as supplied in the request or fetched from the block explorer.
  - `name` `string`: Name of the function, event or error. Absent for constructors, fallback and receive.
  - `type` `string`: Kind of entry: `function`, `constructor`, `event`, `error`, `fallback` or `receive`.
  - `anonymous` `boolean`: For events, whether the event is anonymous (its signature is not stored as a topic).
  - `payable` `boolean`: Legacy flag: whether the function accepts native value. Superseded by `stateMutability`.
  - `constant` `boolean`: Legacy flag: whether the function does not modify state. Superseded by `stateMutability`.
  - `stateMutability` `string`: How the function interacts with state: `pure`, `view`, `nonpayable` or `payable`.
  - `gas` `string`: Gas hint emitted by some compilers, as a decimal string.
  - `inputs` `object[]`: Parameters of the function or event.
    - `name` `string`: Parameter name. Empty for unnamed return values.
    - `type` `string`: Solidity type, for example `address`, `uint256` or `tuple`.
    - `indexed` `boolean`: For event parameters, whether the value is indexed (stored as a topic).
    - `internalType` `unknown`: The type as written in the source, for example a struct or contract name.
    - `components` `object[]`: For `tuple` types, the fields of the struct.
  - `outputs` `object[]`: Return values of the function.
    - `name` `string`: Parameter name. Empty for unnamed return values.
    - `type` `string`: Solidity type, for example `address`, `uint256` or `tuple`.
    - `indexed` `boolean`: For event parameters, whether the value is indexed (stored as a topic).
    - `internalType` `unknown`: The type as written in the source, for example a struct or contract name.
    - `components` `object[]`: For `tuple` types, the fields of the struct.
- `publicVerification` `boolean` _(required)_: Whether the ABI came from the block explorer's public verification rather than from the request.

#### `401`: Missing or invalid credentials.

### Example request

```bash
curl https://api.openfort.io/v1/contracts/con_0cddb398-1dc6-4e6f-8726-9ec7cea85f35
```

```ts
fetch('https://api.openfort.io/v1/contracts/con_0cddb398-1dc6-4e6f-8726-9ec7cea85f35')
```

## Updates a contract object

`POST /v1/contracts/{id}`

### Path parameters

- `id` `string` _(required)_: Specifies the unique contract ID (starts with con_).

### Request body (required) (`application/json`)

- `name` `string`: Specifies the name of the contract (Only for display purposes).
- `chainId` `integer <int32>`: Specifies the chain ID of the contract. Must be a [supported chain](https://www.openfort.io/docs/configuration/chains).
- `deleted` `boolean`: Specifies whether to delete the contract.
- `address` `string`: Specifies the address of the contract.
- `abi` `object[]`: Specifies the ABI of the contract.
  - `name` `string`: Name of the function, event or error. Absent for constructors, fallback and receive.
  - `type` `string`: Kind of entry: `function`, `constructor`, `event`, `error`, `fallback` or `receive`.
  - `anonymous` `boolean`: For events, whether the event is anonymous (its signature is not stored as a topic).
  - `payable` `boolean`: Legacy flag: whether the function accepts native value. Superseded by `stateMutability`.
  - `constant` `boolean`: Legacy flag: whether the function does not modify state. Superseded by `stateMutability`.
  - `stateMutability` `string`: How the function interacts with state: `pure`, `view`, `nonpayable` or `payable`.
  - `gas` `string`: Gas hint emitted by some compilers, as a decimal string.
  - `inputs` `object[]`: Parameters of the function or event.
    - `name` `string`: Parameter name. Empty for unnamed return values.
    - `type` `string`: Solidity type, for example `address`, `uint256` or `tuple`.
    - `indexed` `boolean`: For event parameters, whether the value is indexed (stored as a topic).
    - `internalType` `unknown`: The type as written in the source, for example a struct or contract name.
    - `components` `object[]`: For `tuple` types, the fields of the struct.
  - `outputs` `object[]`: Return values of the function.
    - `name` `string`: Parameter name. Empty for unnamed return values.
    - `type` `string`: Solidity type, for example `address`, `uint256` or `tuple`.
    - `indexed` `boolean`: For event parameters, whether the value is indexed (stored as a topic).
    - `internalType` `unknown`: The type as written in the source, for example a struct or contract name.
    - `components` `object[]`: For `tuple` types, the fields of the struct.
- `publicVerification` `boolean`: Specifies whether to verify the contract publicly.

### Responses

#### `200`: The updated contract.

Body (`application/json`):

- `id` `string` _(required)_: Unique identifier of the object. The prefix tells its type, for example `acc_` for accounts.
- `object` `string` _(required)_: The type of object.
- `createdAt` `integer <int32>` _(required)_: When the object was created, as Unix epoch seconds.
- `name` `string | null` _(required)_: Display name of the contract, or `null` when none was given.
- `chainId` `integer <int32>` _(required)_: The chain ID the contract is deployed on.
- `address` `string` _(required)_: The contract address.
- `deleted` `boolean` _(required)_: Whether the contract has been deleted. Deleted contracts stay readable so existing references keep resolving.
- `abi` `object[]` _(required)_: The contract ABI, as supplied in the request or fetched from the block explorer.
  - `name` `string`: Name of the function, event or error. Absent for constructors, fallback and receive.
  - `type` `string`: Kind of entry: `function`, `constructor`, `event`, `error`, `fallback` or `receive`.
  - `anonymous` `boolean`: For events, whether the event is anonymous (its signature is not stored as a topic).
  - `payable` `boolean`: Legacy flag: whether the function accepts native value. Superseded by `stateMutability`.
  - `constant` `boolean`: Legacy flag: whether the function does not modify state. Superseded by `stateMutability`.
  - `stateMutability` `string`: How the function interacts with state: `pure`, `view`, `nonpayable` or `payable`.
  - `gas` `string`: Gas hint emitted by some compilers, as a decimal string.
  - `inputs` `object[]`: Parameters of the function or event.
    - `name` `string`: Parameter name. Empty for unnamed return values.
    - `type` `string`: Solidity type, for example `address`, `uint256` or `tuple`.
    - `indexed` `boolean`: For event parameters, whether the value is indexed (stored as a topic).
    - `internalType` `unknown`: The type as written in the source, for example a struct or contract name.
    - `components` `object[]`: For `tuple` types, the fields of the struct.
  - `outputs` `object[]`: Return values of the function.
    - `name` `string`: Parameter name. Empty for unnamed return values.
    - `type` `string`: Solidity type, for example `address`, `uint256` or `tuple`.
    - `indexed` `boolean`: For event parameters, whether the value is indexed (stored as a topic).
    - `internalType` `unknown`: The type as written in the source, for example a struct or contract name.
    - `components` `object[]`: For `tuple` types, the fields of the struct.
- `publicVerification` `boolean` _(required)_: Whether the ABI came from the block explorer's public verification rather than from the request.

#### `401`: Missing or invalid credentials.

#### `409`: The request conflicts with the current state of the resource.

### Example request

```bash
curl https://api.openfort.io/v1/contracts/con_0cddb398-1dc6-4e6f-8726-9ec7cea85f35 \
  --request POST \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "NFT Contract",
  "chainId": 80002,
  "deleted": false,
  "address": "0x1234567890abcdef1234567890abcdef12345678",
  "abi": [
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "_owner",
          "type": "address"
        }
      ],
      "stateMutability": "nonpayable",
      "type": "constructor"
    },
    {
      "inputs": [],
      "name": "owner",
      "outputs": [
        {
          "internalType": "address",
          "name": "",
          "type": "address"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    }
  ],
  "publicVerification": false
}'
```

```ts
fetch('https://api.openfort.io/v1/contracts/con_0cddb398-1dc6-4e6f-8726-9ec7cea85f35', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'NFT Contract',
    chainId: 80002,
    deleted: false,
    address: '0x1234567890abcdef1234567890abcdef12345678',
    abi: [
      {
        inputs: [
          {
            internalType: 'address',
            name: '_owner',
            type: 'address'
          }
        ],
        stateMutability: 'nonpayable',
        type: 'constructor'
      },
      {
        inputs: [],
        name: 'owner',
        outputs: [
          {
            internalType: 'address',
            name: '',
            type: 'address'
          }
        ],
        stateMutability: 'view',
        type: 'function'
      }
    ],
    publicVerification: false
  })
})
```

## Deletes a contract object

`DELETE /v1/contracts/{id}`

Delete a contract from the project by providing its contract id.

### Path parameters

- `id` `string` _(required)_: Specifies the unique contract ID (starts with con_).

### Responses

#### `200`: The deleted contract.

Body (`application/json`):

- `id` `string` _(required)_: Identifier of the deleted object.
- `object` `string` _(required)_: The type of the deleted object.
- `deleted` `boolean` _(required)_: Always `true`: the object was deleted.

#### `401`: Missing or invalid credentials.

#### `409`: The request conflicts with the current state of the resource.

### Example request

```bash
curl https://api.openfort.io/v1/contracts/con_0cddb398-1dc6-4e6f-8726-9ec7cea85f35 \
  --request DELETE
```

```ts
fetch('https://api.openfort.io/v1/contracts/con_0cddb398-1dc6-4e6f-8726-9ec7cea85f35', {
  method: 'DELETE'
})
```

## Read on chain contract repositories

`GET /v1/contracts/{id}/read`

Using this endpoint, you can get the repositories returned by any readable
function listed in a contracts ABI. This could be things like querying
the totalSupply of a currency contract, the number of owners of an items
contract, and more.

### Path parameters

- `id` `string` _(required)_: Specifies the unique contract ID (starts with con_).

### Query parameters

- `functionName` `string` _(required)_: The function name of the contract.
- `functionArgs` `unknown[]`: The function arguments of the contract, in string format. Accepts pla_, con_ and acc_ IDs.

### Responses

#### `200`: The decoded result of the call.

Body (`application/json`):

- `id` `string` _(required)_: Unique identifier of the object. The prefix tells its type, for example `acc_` for accounts.
- `object` `string` _(required)_: The type of object.
- `createdAt` `integer <int32>` _(required)_: When the object was created, as Unix epoch seconds.
- `functionName` `string` _(required)_: The contract function that was called.
- `result` `unknown` _(required)_: The decoded return value of the call. Its shape follows the function's ABI outputs.

#### `401`: Missing or invalid credentials.

#### `409`: The request conflicts with the current state of the resource.

### Example request

```bash
curl 'https://api.openfort.io/v1/contracts/con_0cddb398-1dc6-4e6f-8726-9ec7cea85f35/read?functionName=mint&functionArgs=0x662D24Bf7Ea2dD6a7D0935F680a6056b94fE934d'
```

```ts
fetch('https://api.openfort.io/v1/contracts/con_0cddb398-1dc6-4e6f-8726-9ec7cea85f35/read?functionName=mint&functionArgs=0x662D24Bf7Ea2dD6a7D0935F680a6056b94fE934d')
```
