# Deploy

The `Deploy` entity provides a normalized representation of the Casper Network deploy. It is enriched with normalized contract data to make it possible to filter deploys by the contract regardless of the execution type.

## Properties

The `Deploy` entity has the following properties:

| Property                | Type          | Description                                                                                                                                                                                                                                             |
| ----------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `deploy_hash`           | `string(64)`  | Deploy hash represented as a hexadecimal string. Primary deploy identifier.                                                                                                                                                                             |
| `block_hash`            | `string(64)`  | Hash of the block containing the deploy represented as a hexadecimal string.                                                                                                                                                                            |
| `block_height`          | `uint64`      | Height of the block containing the deploy.                                                                                                                                                                                                              |
| `caller_public_key`     | `string(68)`  | Public key of the deploy caller account represented as a hexademical string. May be `null` if the public key is not known, but the `caller_hash` will still be present.                                                                                 |
| `caller_hash`           | `string(64)`  | Hash of the deploy caller account represented as a hexademical string.                                                                                                                                                                                  |
| `version_id`            | `uint8`       | Deploy version identifier: `0` for Casper 1.X deploys, `1` for Casper 2.0 deploys, and `2` for Casper 2.0 transactions.                                                                                                                                 |
| `pricing_mode_id`       | `uint8`       | Pricing mode identifier. Indicates which pricing model applies to the deploy \*                                                                                                                                                                         |
| `gas_price_limit`       | `uint8`       | Maximum allowed gas price that was specified by the caller (used only in `Limited(0)` pricing mode)                                                                                                                                                     |
| `is_standard_payment`   | `uint8`       | Indicates whether the deploy uses the standard payment mechanism or a custom payment contract                                                                                                                                                           |
| `runtime_type_id`       | `uint8`       | Identifies how the deploy was executed: `0` for native execution, `1` for VM version 1, and `2` for VM version 2                                                                                                                                        |
| `consumed_gas`          | `uint8`       | Represents the total amount of gas consumed during the execution of the deploy                                                                                                                                                                          |
| `refund_amount`         | `uint8`       | The amount of gas cost that was refunded to the caller account. In the current Mainnet configuration, 75% of unused payment amount is refunded.                                                                                                         |
| `execution_type_id`     | `uint8`       | [`DeployExecutionType`](https://docs.cspr.cloud/rest-api/deploy/get-deploy-execution-types) identifier, that tells what type of the deploy was executed                                                                                                 |
| `contract_package_hash` | `string(64)`  | Hash of the contract package called by the deploy represented as a hexadecimal string. `null` if the deploy had no contract call.                                                                                                                       |
| `contract_hash`         | `string(64)`  | Hash of the contract called by the deploy represented as a hexadecimal string. `null` if the deploy had no contract call.                                                                                                                               |
| `entry_point_id`        | `uint32`      | Identifier of the [`ContractEntrypoint`](https://docs.cspr.cloud/rest-api/contract-entry-point) called by deploy. `null` if the deploy had no contract call.                                                                                            |
| `args`                  | `JSON`        | Deploy sessions arguments provided for contract execution.                                                                                                                                                                                              |
| `payment_amount`        | `string`      | Payment amount provided by the caller in motes. The type is string to avoid overflow in languages that don't support `uint64`, which is the correct type. `null` if a custom payment contract was provided to the deploy instead of the value in motes. |
| `cost`                  | `string`      | Deploy execution cost. The type is `string` to avoid overflow in languages that don't support `uint64`, which is the correct type.                                                                                                                      |
| `error_message`         | `string(128)` | Error message in case of a failed deploy. `null` for successful. deploys.                                                                                                                                                                               |
| `status`                | `string`      | Deploy status (`pending`, `expired`, or `processed`).                                                                                                                                                                                                   |
| `timestamp`             | `string`      | Deploy creation timestamp in the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.                                                                                                                                                             |

### Pricing Mode Supported Values

| Name      | Value | Description                                                                  |
| --------- | ----- | ---------------------------------------------------------------------------- |
| `Limited` | `0`   | Default pricing mode used in Casper 1.X versions.                            |
| `Fixed`   | `1`   | Introduced in Casper 2.0. Uses a flat-fee model for deploy execution.        |
| `Prepaid` | `2`   | Allows users to prepay for deploys. Intended for future or custom use cases. |

**Example**

```json
{
  "args": {
    "amount": {
      "cl_type": "U512",
      "parsed": "2500000000"
    },
    "id": {
      "cl_type": {
        "Option": "U64"
      },
      "parsed": null
    },
    "target": {
      "cl_type": {
        "ByteArray": 32
      },
      "parsed": "536345751b7c6c6299d5ef10862d76736ed062bc32c1dabcd1179c06469d93ca"
    }
  },
  "block_hash": "d76b4ce5281f2306911a0e5e9ac0b29f1f4daf36f4636e78599ce64a7f7528a1",
  "block_height": 2404577,
  "caller_hash": "048a54220799a48171743407c086668bdcc788e2a31e4185fe52d0682634f888",
  "caller_public_key": "020304811a7b142c32860cb1c114f23b0754215918d819f485b0a201af6cde70fa6c",
  "consumed_gas": "100000000",
  "contract_hash": "010c3fe81b7b862e50c77ef9a958a05bfa98444f26f96f23d37a13c96244cfb7",
  "contract_package_hash": "9824d60dc3a5c44a20b9fd260a412437933835b52fc683d8ae36e4ec2114843e",
  "cost": "100000000",
  "deploy_hash": "88461218a5e972fcda1d764d7cc4edb2e0c3a538123b97890d484f43c55935f5",
  "entry_point_id": 10,
  "error_message": null,
  "execution_type_id": 6,
  "gas_price_limit": 1,
  "is_standard_payment": false,
  "payment_amount": "100000000",
  "pricing_mode_id": 0,
  "refund_amount": "0",
  "runtime_type_id": 0,
  "status": "processed",
  "timestamp": "2024-01-08T15:24:47Z",
  "version_id": 0
}
```

## Optional properties

Depending on the endpoint some of the following optional properties may be included in the `Deploy` entity:

| Property                   | Type                                                                                  | Description                                                                                                         |
| -------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| `account_info`             | [`AccountInfo`](https://docs.cspr.cloud/rest-api/account-info)                        | [Account info](https://github.com/make-software/casper-account-info-contract) provided by the deploy caller account |
| `centralized_account_info` | [`CentralizedAccountInfo`](https://docs.cspr.cloud/rest-api/centralized-account-info) | Account information available for known accounts provided by CSPR.cloud team                                        |
| `caller_cspr_name`         | `string`                                                                              | Primary CSPR.name of the deploy caller account                                                                      |
| `contract_package`         | [`ContractPackage`](https://docs.cspr.cloud/rest-api/contract-package)                | [`ContractPackage`](https://docs.cspr.cloud/rest-api/contract-package) called by deploy.                            |
| `contract`                 | [`Contract`](https://docs.cspr.cloud/rest-api/contract)                               | [`Contract`](https://docs.cspr.cloud/rest-api/contract) called by deploy.                                           |
| `contract_entrypoint`      | [`ContractEntrypoint`](https://docs.cspr.cloud/rest-api/contract-entry-point)         | [`ContractEntrypoint`](https://docs.cspr.cloud/rest-api/contract-entry-point) called by deploy.                     |
| `rate`                     | `float32`                                                                             | CSPR rate for specified currency that was relevant at the moment of deploy creation.                                |
| `transfers`                | \[][`Transfer`](https://docs.cspr.cloud/rest-api/transfer)                            | List of transfers executed during deploy execution                                                                  |

## Relations

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

| Entity                                                                                      | Mapping property        | Description                                                                                                                                    |
| ------------------------------------------------------------------------------------------- | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| [`Account`](https://docs.cspr.cloud/rest-api/account)                                       | `caller_public_key`     | Deploys are called by accounts.                                                                                                                |
| [`Block`](https://docs.cspr.cloud/rest-api/block)                                           | `block_hash`            | Deploys are executed in blocks.                                                                                                                |
| [`Contract`](https://docs.cspr.cloud/rest-api/contract)                                     | `contract_hash`         | Deploys can call contracts, and contracts are deployed with deploys.                                                                           |
| [`ContractEntrypoint`](https://docs.cspr.cloud/rest-api/contract-package)                   | `entry_point`           | Deploys can call entry points.                                                                                                                 |
| [`ContractPackage`](https://docs.cspr.cloud/rest-api/contract-package)                      | `contract_package_hash` | Deploys can call contracts in contract packages.                                                                                               |
| [`DeployExecutionType`](https://docs.cspr.cloud/rest-api/deploy/get-deploy-execution-types) | `execution_type_id`     | Deploys call contracts via different [execution types](https://docs.casper.network/developers/writing-onchain-code/calling-contracts/).        |
| [`Fungible token action`](https://docs.cspr.cloud/rest-api/fungible-token-action)           | `deploy_hash`           | Fungible token actions are result of deploy execution.                                                                                         |
| [`NFT`](https://docs.cspr.cloud/rest-api/non-fungible-token)                                |                         | NFTs are created as result of deploy execution. There is no direct mapping, but rather a semantic relationship between deploys and nft tokens. |
| [`NFT Action`](https://docs.cspr.cloud/rest-api/non-fungible-token-action)                  | `deploy_hash`           | NFT actions are result of deploy execution.                                                                                                    |
| [`Transfer`](https://docs.cspr.cloud/rest-api/transfer)                                     | `deploy_hash`           | Transfers are result of deploy execution.                                                                                                      |

## Endpoints

The `Deploy` entity has the following endpoints:

* [Get deploy](https://docs.cspr.cloud/rest-api/deploy/get-deploy)
* [Get deploys](https://docs.cspr.cloud/rest-api/deploy/get-deploys)
* [Get account deploys](https://docs.cspr.cloud/rest-api/deploy/get-account-deploys)
* [Get block deploys](https://docs.cspr.cloud/rest-api/deploy/get-block-deploys)

## Relation endpoints

* [Get deploy execution types](https://docs.cspr.cloud/rest-api/deploy/get-deploy-execution-types)
