# Contract

The `Contract` entity offers a normalized representation of the Casper Network [Contract](https://docs.casper.network/developers/json-rpc/types_chain/#contract) without including entry point hashes, which can be queried separately using the [Contract entry point](https://docs.cspr.cloud/1.1.x/rest-api/contract-entry-point) API. Additionally, this entity omits the contract's named keys but utilizes them for identifying the contract's type.

## Properties

The `Contract` entity has the following properties:

| Property                | Type         | Description                                                                                                                                       |
| ----------------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `contract_hash`         | `string(64)` | Contract hash represented as a hexadecimal string. Unique contract identifier                                                                     |
| `contract_package_hash` | `string(64)` | Hash of the contract package, this contract version is a part of, represented as a hexadecimal string                                             |
| `block_height`          | `uint64`     | Height of the block in which the contract was deployed to the network                                                                             |
| `deploy_hash`           | `string(64)` | Hash of the deploy that deployed the contract to the network represented as a hexadecimal string                                                  |
| `contract_type_id`      | `uint8`      | Identifier representing the type of the contract, check the types list [here](https://docs.cspr.cloud/1.1.x/rest-api/contract/get-contract-types) |
| `timestamp`             | `uint16`     | Timestamp indicating when the contract was created                                                                                                |
| `contract_version`      | `uint16`     | Version number associated with the contract                                                                                                       |
| `is_disabled`           | `bool`       | Indicates whether the contract is currently disabled                                                                                              |
| `timestamp`             | `datetime`   | Timestamp indicating when the contract was created                                                                                                |
| `contract_version`      | `uint16`     | Version number associated with the contract                                                                                                       |
| `is_disabled`           | `bool`       | Indicates whether the contract is currently disabled                                                                                              |

**Example**

```json
{
  "contract_hash": "8a2feaa4e86841c1c6f40f1779e1e1cb1d9d4d52a0eb82a8962829646524e732",
  "contract_package_hash": "ae2feaa4e86841c1c6f40f1779e1e1cb1d9d4d52a0eb82a8962829646524e744",
  "deploy_hash": "1a2feaa4e86841c1c6f40f1779e1e1cb1d9d4d52a0eb82a8962829646524e755",
  "block_height": 2764649,
  "contract_type_id": 2,
  "timestamp": "2023-01-01T12:00:00Z",
  "contract_version": 1,
  "is_disabled": false
}
```

## Optional properties

Depending on the endpoint, the following optional properties may be included in the `Contract` entity:

| Property           | Type                                                                       | Description                                          |
| ------------------ | -------------------------------------------------------------------------- | ---------------------------------------------------- |
| `contract_package` | [ContractPackage](https://docs.cspr.cloud/1.1.x/rest-api/contract-package) | Contract package, this contract version is a part of |

## Relations

The `Contract` entity has the following relations with other entities:

| Entity                                                                              | Mapping property             | Description                                                                                |
| ----------------------------------------------------------------------------------- | ---------------------------- | ------------------------------------------------------------------------------------------ |
| [`Deploy`](https://docs.cspr.cloud/1.1.x/rest-api/deploy)                           | `contract_hash, deploy_hash` | Contracts are deployed to the network with a deploy call. Deploys can be the contract call |
| [`ContractEntrypoint`](https://docs.cspr.cloud/1.1.x/rest-api/contract-entry-point) | `contract_hash`              | Contracts can have endpoints                                                               |
| [`ContractPackage`](https://docs.cspr.cloud/1.1.x/rest-api/contract-package)        | `contract_package_hash`      | Contracts are different versions of the same smart contract under the contract package     |

## Endpoints

The `Contract` entity has the following endpoints:

* [Get contract](https://docs.cspr.cloud/1.1.x/rest-api/contract/get-contract)
* [Get contracts](https://docs.cspr.cloud/1.1.x/rest-api/contract/get-contracts)
* [Get contract package contracts](https://docs.cspr.cloud/1.1.x/rest-api/contract/get-contracts-by-contract-package)

## Relation endpoints

The `Contract` entity has the following relation endpoints:

* [Get contract entry points](https://docs.cspr.cloud/1.1.x/rest-api/contract-entry-point/get-contract-entry-points)
* [Get contract types](https://docs.cspr.cloud/1.1.x/rest-api/contract/get-contract-types)
