# escrow\_client

This client enables to perform actions on Escrow contracts and obtain information from both the contracts and subgraph.

Internally, the SDK will use one network or another according to the network ID of the web3. To use this client, you need to create Web3 instance, and configure default account, as well as some middlewares.

## Code Example

* With Signer

```python
from eth_typing import URI
from web3 import Web3
from web3.middleware import construct_sign_and_send_raw_middleware
from web3.providers.auto import load_provider_from_uri

from human_protocol_sdk.escrow import EscrowClient

def get_w3_with_priv_key(priv_key: str):
    w3 = Web3(load_provider_from_uri(URI("http://localhost:8545")))
    gas_payer = w3.eth.account.from_key(priv_key)
    w3.eth.default_account = gas_payer.address
    w3.middleware_onion.add(
        construct_sign_and_send_raw_middleware(gas_payer),
        "construct_sign_and_send_raw_middleware",
    )
    return (w3, gas_payer)

(w3, gas_payer) = get_w3_with_priv_key('YOUR_PRIVATE_KEY')
escrow_client = EscrowClient(w3)
```

* Without Signer (For read operations only)

```python
from eth_typing import URI
from web3 import Web3
from web3.providers.auto import load_provider_from_uri

from human_protocol_sdk.escrow import EscrowClient

w3 = Web3(load_provider_from_uri(URI("http://localhost:8545")))
escrow_client = EscrowClient(w3)
```

## Module

### *class* human\_protocol\_sdk.escrow\.escrow\_client.EscrowCancel(tx\_hash, amount\_refunded)

Bases: `object`

#### \_\_init\_\_(tx\_hash, amount\_refunded)

Represents the result of an escrow cancellation transaction.

* **Parameters:**
  * **tx\_hash** (`str`) – The hash of the transaction that cancelled the escrow.
  * **amount\_refunded** (`any`) – The amount refunded during the escrow cancellation.

### *class* human\_protocol\_sdk.escrow\.escrow\_client.EscrowClient(web3)

Bases: `object`

A client class to interact with the escrow smart contract.

#### \_\_init\_\_(web3)

Initializes a Escrow instance.

* **Parameters:** **web3** (`Web3`) – The Web3 object

#### add\_trusted\_handlers(escrow\_address, handlers, tx\_options=None)

Adds an array of addresses to the trusted handlers list.

* **Parameters:**
  * **escrow\_address** (`str`) – Address of the escrow
  * **handlers** (`List`\[`str`]) – Array of trusted handler addresses
  * **tx\_options** (`Optional`\[`TxParams`]) – (Optional) Additional transaction parameters
* **Return type:** `None`
* **Returns:** None
* **Raises:** [**EscrowClientError**](#human_protocol_sdk.escrow.escrow_client.EscrowClientError) – If an error occurs while checking the parameters
* **Example:**

  ```python
  from eth_typing import URI
  from web3 import Web3
  from web3.middleware import construct_sign_and_send_raw_middleware
  from web3.providers.auto import load_provider_from_uri

  from human_protocol_sdk.escrow import EscrowClient

  def get_w3_with_priv_key(priv_key: str):
      w3 = Web3(load_provider_from_uri(URI("http://localhost:8545")))
      gas_payer = w3.eth.account.from_key(priv_key)
      w3.eth.default_account = gas_payer.address
      w3.middleware_onion.add(
          construct_sign_and_send_raw_middleware(gas_payer),
          "construct_sign_and_send_raw_middleware",
      )
      return (w3, gas_payer)

  (w3, gas_payer) = get_w3_with_priv_key('YOUR_PRIVATE_KEY')
  escrow_client = EscrowClient(w3)

  trusted_handlers = [
      '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
      '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'
  ]
  escrow_client.add_trusted_handlers(
      "0x62dD51230A30401C455c8398d06F85e4EaB6309f",
      trusted_handlers
  )
  ```

#### bulk\_payout(escrow\_address, recipients, amounts, final\_results\_url, final\_results\_hash, txId, force\_complete=False, tx\_options=None)

Pays out the amounts specified to the workers and sets the URL of the final results file.

* **Parameters:**
  * **escrow\_address** (`str`) – Address of the escrow
  * **recipients** (`List`\[`str`]) – Array of recipient addresses
  * **amounts** (`List`\[`Decimal`]) – Array of amounts the recipients will receive
  * **final\_results\_url** (`str`) – Final results file URL
  * **final\_results\_hash** (`str`) – Final results file hash
  * **txId** (`Decimal`) – Serial number of the bulks
  * **force\_complete** (`Optional`\[`bool`]) – (Optional) Indicates if remaining balance should be transferred to the escrow creator
  * **tx\_options** (`Optional`\[`TxParams`]) – (Optional) Additional transaction parameters
* **Return type:** `None`
* **Returns:** None
* **Raises:** [**EscrowClientError**](#human_protocol_sdk.escrow.escrow_client.EscrowClientError) – If an error occurs while checking the parameters
* **Example:**

  ```python
  from eth_typing import URI
  from web3 import Web3
  from web3.middleware import construct_sign_and_send_raw_middleware
  from web3.providers.auto import load_provider_from_uri

  from human_protocol_sdk.escrow import EscrowClient

  def get_w3_with_priv_key(priv_key: str):
      w3 = Web3(load_provider_from_uri(URI("http://localhost:8545")))
      gas_payer = w3.eth.account.from_key(priv_key)
      w3.eth.default_account = gas_payer.address
      w3.middleware_onion.add(
          construct_sign_and_send_raw_middleware(gas_payer),
          "construct_sign_and_send_raw_middleware",
      )
      return (w3, gas_payer)

  (w3, gas_payer) = get_w3_with_priv_key('YOUR_PRIVATE_KEY')
  escrow_client = EscrowClient(w3)

  recipients = [
      '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
      '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92267'
  ]
  amounts = [
      Web3.to_wei(5, 'ether'),
      Web3.to_wei(10, 'ether')
  ]
  results_url = 'http://localhost/results.json'
  results_hash = 'b5dad76bf6772c0f07fd5e048f6e75a5f86ee079'

  escrow_client.bulk_payout(
      "0x62dD51230A30401C455c8398d06F85e4EaB6309f",
      recipients,
      amounts,
      results_url,
      results_hash,
      1
  )
  ```

#### cancel(escrow\_address, tx\_options=None)

Cancels the specified escrow and sends the balance to the canceler.

* **Parameters:**
  * **escrow\_address** (`str`) – Address of the escrow to cancel
  * **tx\_options** (`Optional`\[`TxParams`]) – (Optional) Additional transaction parameters
* **Return type:** [`EscrowCancel`](#human_protocol_sdk.escrow.escrow_client.EscrowCancel)
* **Returns:** EscrowCancel: An instance of the EscrowCancel class containing details of the cancellation transaction, including the transaction hash and the amount refunded.
* **Raises:**
  * [**EscrowClientError**](#human_protocol_sdk.escrow.escrow_client.EscrowClientError) – If an error occurs while checking the parameters
  * [**EscrowClientError**](#human_protocol_sdk.escrow.escrow_client.EscrowClientError) – If the transfer event associated with the cancellation is not found in the transaction logs
* **Example:**

  ```python
  from eth_typing import URI
  from web3 import Web3
  from web3.middleware import construct_sign_and_send_raw_middleware
  from web3.providers.auto import load_provider_from_uri

  from human_protocol_sdk.escrow import EscrowClient

  def get_w3_with_priv_key(priv_key: str):
      w3 = Web3(load_provider_from_uri(URI("http://localhost:8545")))
      gas_payer = w3.eth.account.from_key(priv_key)
      w3.eth.default_account = gas_payer.address
      w3.middleware_onion.add(
          construct_sign_and_send_raw_middleware(gas_payer),
          "construct_sign_and_send_raw_middleware",
      )
      return (w3, gas_payer)

  (w3, gas_payer) = get_w3_with_priv_key('YOUR_PRIVATE_KEY')
  escrow_client = EscrowClient(w3)

  escrow_cancel_data = escrow_client.cancel(
      "0x62dD51230A30401C455c8398d06F85e4EaB6309f"
  )
  ```

#### complete(escrow\_address, tx\_options=None)

Sets the status of an escrow to completed.

* **Parameters:**
  * **escrow\_address** (`str`) – Address of the escrow to complete
  * **tx\_options** (`Optional`\[`TxParams`]) – (Optional) Additional transaction parameters
* **Return type:** `None`
* **Returns:** None
* **Raises:** [**EscrowClientError**](#human_protocol_sdk.escrow.escrow_client.EscrowClientError) – If an error occurs while checking the parameters
* **Example:**

  ```python
  from eth_typing import URI
  from web3 import Web3
  from web3.middleware import construct_sign_and_send_raw_middleware
  from web3.providers.auto import load_provider_from_uri

  from human_protocol_sdk.escrow import EscrowClient

  def get_w3_with_priv_key(priv_key: str):
      w3 = Web3(load_provider_from_uri(URI("http://localhost:8545")))
      gas_payer = w3.eth.account.from_key(priv_key)
      w3.eth.default_account = gas_payer.address
      w3.middleware_onion.add(
          construct_sign_and_send_raw_middleware(gas_payer),
          "construct_sign_and_send_raw_middleware",
      )
      return (w3, gas_payer)

  (w3, gas_payer) = get_w3_with_priv_key('YOUR_PRIVATE_KEY')
  escrow_client = EscrowClient(w3)

  escrow_client.complete("0x62dD51230A30401C455c8398d06F85e4EaB6309f")
  ```

#### create\_bulk\_payout\_transaction(escrow\_address, recipients, amounts, final\_results\_url, final\_results\_hash, txId, force\_complete=False, tx\_options=None)

Creates a prepared transaction for bulk payout without signing or sending it.

* **Parameters:**
  * **escrow\_address** (`str`) – Address of the escrow
  * **recipients** (`List`\[`str`]) – Array of recipient addresses
  * **amounts** (`List`\[`Decimal`]) – Array of amounts the recipients will receive
  * **final\_results\_url** (`str`) – Final results file URL
  * **final\_results\_hash** (`str`) – Final results file hash
  * **txId** (`Decimal`) – Serial number of the bulks
  * **tx\_options** (`Optional`\[`TxParams`]) – (Optional) Additional transaction parameters
* **Return type:** `TxParams`
* **Returns:** A dictionary containing the prepared transaction
* **Raises:** [**EscrowClientError**](#human_protocol_sdk.escrow.escrow_client.EscrowClientError) – If an error occurs while checking the parameters
* **Example:**

  ```python
  from eth_typing import URI
  from web3 import Web3
  from web3.middleware import construct_sign_and_send_raw_middleware
  from web3.providers.auto import load_provider_from_uri

  from human_protocol_sdk.escrow import EscrowClient

  def get_w3_with_priv_key(priv_key: str):
      w3 = Web3(load_provider_from_uri(URI("http://localhost:8545")))
      gas_payer = w3.eth.account.from_key(priv_key)
      w3.eth.default_account = gas_payer.address
      w3.middleware_onion.add(
          construct_sign_and_send_raw_middleware(gas_payer),
          "construct_sign_and_send_raw_middleware",
      )
      return (w3, gas_payer)

  (w3, gas_payer) = get_w3_with_priv_key('YOUR_PRIVATE_KEY')
  escrow_client = EscrowClient(w3)

  recipients = [
      '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
      '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92267'
  ]
  amounts = [
      Web3.to_wei(5, 'ether'),
      Web3.to_wei(10, 'ether')
  ]
  results_url = 'http://localhost/results.json'
  results_hash = 'b5dad76bf6772c0f07fd5e048f6e75a5f86ee079'

  transaction = escrow_client.create_bulk_payout_transaction(
      "0x62dD51230A30401C455c8398d06F85e4EaB6309f",
      recipients,
      amounts,
      results_url,
      results_hash,
      1,
      false
  )

  print(f"Transaction: {transaction}")

  signed_transaction = w3.eth.account.sign_transaction(
      transaction, private_key
  )
  tx_hash = w3.eth.send_raw_transaction(
      signed_transaction.raw_transaction
  )
  tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
  print(f"Transaction sent with hash: {tx_hash.hex()}")
  print(f"Transaction receipt: {tx_receipt}")
  ```

#### create\_escrow(token\_address, trusted\_handlers, job\_requester\_id, tx\_options=None)

Creates a new escrow contract.

* **Parameters:**
  * **token\_address** (`str`) – Address of the token to be used in the escrow
  * **trusted\_handlers** (`List`\[`str`]) – List of trusted handler addresses
  * **job\_requester\_id** (`str`) – ID of the job requester
  * **tx\_options** (`Optional`\[`TxParams`]) – (Optional) Transaction options
* **Return type:** `str`
* **Returns:** Address of the created escrow contract
* **Example:**

  ```python
  from eth_typing import URI
  from web3 import Web3
  from web3.middleware import construct_sign_and_send_raw_middleware
  from web3.providers.auto import load_provider_from_uri

  from human_protocol_sdk.escrow import EscrowClient

  def get_w3_with_priv_key(priv_key: str):
      w3 = Web3(load_provider_from_uri(
          URI("http://localhost:8545")))
      gas_payer = w3.eth.account.from_key(priv_key)
      w3.eth.default_account = gas_payer.address
      w3.middleware_onion.add(
          construct_sign_and_send_raw_middleware(gas_payer),
          "construct_sign_and_send_raw_middleware",
      )
      return (w3, gas_payer)

  (w3, gas_payer) = get_w3_with_priv_key('YOUR_PRIVATE_KEY')
  escrow_client = EscrowClient(w3)

  token_address = '0x1234567890abcdef1234567890abcdef12345678'
  trusted_handlers = [
      '0xabcdefabcdefabcdefabcdefabcdefabcdefabcdef',
      '0xabcdefabcdefabcdefabcdefabcdefabcdefabcdef'
  ]
  job_requester_id = 'job-requester'
  escrow_address = escrow_client.create_escrow(
      token_address,
      trusted_handlers,
      job_requester_id
  )
  ```

#### ensure\_correct\_bulk\_payout\_input(escrow\_address, recipients, amounts, final\_results\_url, final\_results\_hash)

Validates input parameters for bulk payout operations.

* **Parameters:**
  * **escrow\_address** (`str`) – Address of the escrow
  * **recipients** (`List`\[`str`]) – Array of recipient addresses
  * **amounts** (`List`\[`Decimal`]) – Array of amounts the recipients will receive
  * **final\_results\_url** (`str`) – Final results file URL
  * **final\_results\_hash** (`str`) – Final results file hash
* **Return type:** `None`
* **Returns:** None
* **Raises:** [**EscrowClientError**](#human_protocol_sdk.escrow.escrow_client.EscrowClientError) – If validation fails

#### fund(escrow\_address, amount, tx\_options=None)

Adds funds to the escrow.

* **Parameters:**
  * **escrow\_address** (`str`) – Address of the escrow to fund
  * **amount** (`Decimal`) – Amount to be added as funds
  * **tx\_options** (`Optional`\[`TxParams`]) – (Optional) Additional transaction parameters
* **Return type:** `None`
* **Returns:** None
* **Raises:** [**EscrowClientError**](#human_protocol_sdk.escrow.escrow_client.EscrowClientError) – If an error occurs while checking the parameters
* **Example:**

  ```python
  from eth_typing import URI
  from web3 import Web3
  from web3.middleware import construct_sign_and_send_raw_middleware
  from web3.providers.auto import load_provider_from_uri

  from human_protocol_sdk.escrow import EscrowClient

  def get_w3_with_priv_key(priv_key: str):
      w3 = Web3(load_provider_from_uri(URI("http://localhost:8545")))
      gas_payer = w3.eth.account.from_key(priv_key)
      w3.eth.default_account = gas_payer.address
      w3.middleware_onion.add(
          construct_sign_and_send_raw_middleware(gas_payer),
          "construct_sign_and_send_raw_middleware",
      )
      return (w3, gas_payer)

  (w3, gas_payer) = get_w3_with_priv_key('YOUR_PRIVATE_KEY')
  escrow_client = EscrowClient(w3)

  amount = Web3.to_wei(5, 'ether')  # convert from ETH to WEI
  escrow_client.fund(
      "0x62dD51230A30401C455c8398d06F85e4EaB6309f", amount
  )
  ```

#### get\_balance(escrow\_address)

Gets the balance for a specified escrow address.

* **Parameters:** **escrow\_address** (`str`) – Address of the escrow
* **Return type:** `Decimal`
* **Returns:** Value of the balance
* **Raises:** [**EscrowClientError**](#human_protocol_sdk.escrow.escrow_client.EscrowClientError) – If an error occurs while checking the parameters
* **Example:**

  ```python
  from eth_typing import URI
  from web3 import Web3
  from web3.providers.auto import load_provider_from_uri

  from human_protocol_sdk.escrow import EscrowClient

  w3 = Web3(load_provider_from_uri(URI("http://localhost:8545")))
  escrow_client = EscrowClient(w3)

  balance = escrow_client.get_balance(
      "0x62dD51230A30401C455c8398d06F85e4EaB6309f"
  )
  ```

#### get\_exchange\_oracle\_address(escrow\_address)

Gets the exchange oracle address of the escrow.

* **Parameters:** **escrow\_address** (`str`) – Address of the escrow
* **Return type:** `str`
* **Returns:** Exchange oracle address
* **Raises:** [**EscrowClientError**](#human_protocol_sdk.escrow.escrow_client.EscrowClientError) – If an error occurs while checking the parameters
* **Example:**

  ```python
  from eth_typing import URI
  from web3 import Web3
  from web3.providers.auto import load_provider_from_uri

  from human_protocol_sdk.escrow import EscrowClient

  w3 = Web3(load_provider_from_uri(URI("http://localhost:8545")))
  escrow_client = EscrowClient(w3)

  exchange_oracle = escrow_client.get_exchange_oracle_address(
      "0x62dD51230A30401C455c8398d06F85e4EaB6309f"
  )
  ```

#### get\_factory\_address(escrow\_address)

Gets the escrow factory address of the escrow.

* **Parameters:** **escrow\_address** (`str`) – Address of the escrow
* **Return type:** `str`
* **Returns:** Escrow factory address
* **Raises:** [**EscrowClientError**](#human_protocol_sdk.escrow.escrow_client.EscrowClientError) – If an error occurs while checking the parameters
* **Example:**

  ```python
  from eth_typing import URI
  from web3 import Web3
  from web3.providers.auto import load_provider_from_uri

  from human_protocol_sdk.escrow import EscrowClient

  w3 = Web3(load_provider_from_uri(URI("http://localhost:8545")))
  escrow_client = EscrowClient(w3)

  escrow_factory = escrow_client.get_factory_address(
      "0x62dD51230A30401C455c8398d06F85e4EaB6309f"
  )
  ```

#### get\_intermediate\_results\_url(escrow\_address)

Gets the intermediate results file URL.

* **Parameters:** **escrow\_address** (`str`) – Address of the escrow
* **Return type:** `str`
* **Returns:** Intermediate results file url
* **Raises:** [**EscrowClientError**](#human_protocol_sdk.escrow.escrow_client.EscrowClientError) – If an error occurs while checking the parameters
* **Example:**

  ```python
  from eth_typing import URI
  from web3 import Web3
  from web3.providers.auto import load_provider_from_uri

  from human_protocol_sdk.escrow import EscrowClient

  w3 = Web3(load_provider_from_uri(URI("http://localhost:8545")))
  escrow_client = EscrowClient(w3)

  url = escrow_client.get_intermediate_results_url(
      "0x62dD51230A30401C455c8398d06F85e4EaB6309f"
  )
  ```

#### get\_job\_launcher\_address(escrow\_address)

Gets the job launcher address of the escrow.

* **Parameters:** **escrow\_address** (`str`) – Address of the escrow
* **Return type:** `str`
* **Returns:** Job launcher address
* **Raises:** [**EscrowClientError**](#human_protocol_sdk.escrow.escrow_client.EscrowClientError) – If an error occurs while checking the parameters
* **Example:**

  ```python
  from eth_typing import URI
  from web3 import Web3
  from web3.providers.auto import load_provider_from_uri

  from human_protocol_sdk.escrow import EscrowClient

  w3 = Web3(load_provider_from_uri(URI("http://localhost:8545")))
  escrow_client = EscrowClient(w3)

  job_launcher = escrow_client.get_job_launcher_address(
      "0x62dD51230A30401C455c8398d06F85e4EaB6309f"
  )
  ```

#### get\_manifest\_hash(escrow\_address)

Gets the manifest file hash.

* **Parameters:** **escrow\_address** (`str`) – Address of the escrow
* **Return type:** `str`
* **Returns:** Manifest file hash
* **Raises:** [**EscrowClientError**](#human_protocol_sdk.escrow.escrow_client.EscrowClientError) – If an error occurs while checking the parameters
* **Example:**

  ```python
  from eth_typing import URI
  from web3 import Web3
  from web3.providers.auto import load_provider_from_uri

  from human_protocol_sdk.escrow import EscrowClient

  w3 = Web3(load_provider_from_uri(URI("http://localhost:8545")))
  escrow_client = EscrowClient(w3)

  manifest_hash = escrow_client.get_manifest_hash(
      "0x62dD51230A30401C455c8398d06F85e4EaB6309f"
  )
  ```

#### get\_manifest\_url(escrow\_address)

Gets the manifest file URL.

* **Parameters:** **escrow\_address** (`str`) – Address of the escrow
* **Return str:** Manifest file url
* **Raises:** [**EscrowClientError**](#human_protocol_sdk.escrow.escrow_client.EscrowClientError) – If an error occurs while checking the parameters
* **Example:**

  ```python
  from eth_typing import URI
  from web3 import Web3
  from web3.providers.auto import load_provider_from_uri

  from human_protocol_sdk.escrow import EscrowClient

  w3 = Web3(load_provider_from_uri(URI("http://localhost:8545")))
  escrow_client = EscrowClient(w3)

  url = escrow_client.get_manifest_url(
      "0x62dD51230A30401C455c8398d06F85e4EaB6309f"
  )
  ```
* **Return type:** `str`

#### get\_recording\_oracle\_address(escrow\_address)

Gets the recording oracle address of the escrow.

* **Parameters:** **escrow\_address** (`str`) – Address of the escrow
* **Return type:** `str`
* **Returns:** Recording oracle address
* **Raises:** [**EscrowClientError**](#human_protocol_sdk.escrow.escrow_client.EscrowClientError) – If an error occurs while checking the parameters
* **Example:**

  ```python
  from eth_typing import URI
  from web3 import Web3
  from web3.providers.auto import load_provider_from_uri

  from human_protocol_sdk.escrow import EscrowClient

  w3 = Web3(load_provider_from_uri(URI("http://localhost:8545")))
  escrow_client = EscrowClient(w3)

  recording_oracle = escrow_client.get_recording_oracle_address(
      "0x62dD51230A30401C455c8398d06F85e4EaB6309f"
  )
  ```

#### get\_reputation\_oracle\_address(escrow\_address)

Gets the reputation oracle address of the escrow.

* **Parameters:** **escrow\_address** (`str`) – Address of the escrow
* **Return type:** `str`
* **Returns:** Reputation oracle address
* **Raises:** [**EscrowClientError**](#human_protocol_sdk.escrow.escrow_client.EscrowClientError) – If an error occurs while checking the parameters
* **Example:**

  ```python
  from eth_typing import URI
  from web3 import Web3
  from web3.providers.auto import load_provider_from_uri

  from human_protocol_sdk.escrow import EscrowClient

  w3 = Web3(load_provider_from_uri(URI("http://localhost:8545")))
  escrow_client = EscrowClient(w3)

  reputation_oracle = escrow_client.get_reputation_oracle_address(
      "0x62dD51230A30401C455c8398d06F85e4EaB6309f"
  )
  ```

#### get\_results\_url(escrow\_address)

Gets the results file URL.

* **Parameters:** **escrow\_address** (`str`) – Address of the escrow
* **Return type:** `str`
* **Returns:** Results file url
* **Raises:** [**EscrowClientError**](#human_protocol_sdk.escrow.escrow_client.EscrowClientError) – If an error occurs while checking the parameters
* **Example:**

  ```python
  from eth_typing import URI
  from web3 import Web3
  from web3.providers.auto import load_provider_from_uri

  from human_protocol_sdk.escrow import EscrowClient

  w3 = Web3(load_provider_from_uri(URI("http://localhost:8545")))
  escrow_client = EscrowClient(w3)

  url = escrow_client.get_results_url(
      "0x62dD51230A30401C455c8398d06F85e4EaB6309f"
  )
  ```

#### get\_status(escrow\_address)

Gets the current status of the escrow.

* **Parameters:** **escrow\_address** (`str`) – Address of the escrow
* **Return type:** [`Status`](https://sdk.humanprotocol.org/human-protocol-sdk/v4.0.1/human_protocol_sdk.constants#human_protocol_sdk.constants.Status)
* **Returns:** Current escrow status
* **Raises:** [**EscrowClientError**](#human_protocol_sdk.escrow.escrow_client.EscrowClientError) – If an error occurs while checking the parameters
* **Example:**

  ```python
  from eth_typing import URI
  from web3 import Web3
  from web3.providers.auto import load_provider_from_uri

  from human_protocol_sdk.escrow import EscrowClient

  w3 = Web3(load_provider_from_uri(URI("http://localhost:8545")))
  escrow_client = EscrowClient(w3)

  status = escrow_client.get_status(
      "0x62dD51230A30401C455c8398d06F85e4EaB6309f"
  )
  ```

#### get\_token\_address(escrow\_address)

Gets the address of the token used to fund the escrow.

* **Parameters:** **escrow\_address** (`str`) – Address of the escrow
* **Return type:** `str`
* **Returns:** Address of the token
* **Raises:** [**EscrowClientError**](#human_protocol_sdk.escrow.escrow_client.EscrowClientError) – If an error occurs while checking the parameters
* **Example:**

  ```python
  from eth_typing import URI
  from web3 import Web3
  from web3.providers.auto import load_provider_from_uri

  from human_protocol_sdk.escrow import EscrowClient

  w3 = Web3(load_provider_from_uri(URI("http://localhost:8545")))
  escrow_client = EscrowClient(w3)

  token_address = escrow_client.get_token_address(
      "0x62dD51230A30401C455c8398d06F85e4EaB6309f"
  )
  ```

#### setup(escrow\_address, escrow\_config, tx\_options=None)

Sets up the parameters of the escrow.

* **Parameters:**
  * **escrow\_address** (`str`) – Address of the escrow contract
  * **escrow\_config** ([`EscrowConfig`](#human_protocol_sdk.escrow.escrow_client.EscrowConfig)) – Configuration parameters for the escrow
  * **tx\_options** (`Optional`\[`TxParams`]) – (Optional) Transaction options
* **Example:**

  ```python
  from eth_typing import URI
  from web3 import Web3
  from web3.middleware import construct_sign_and_send_raw_middleware
  from web3.providers.auto import load_provider_from_uri

  from human_protocol_sdk.escrow import EscrowClient

  def get_w3_with_priv_key(priv_key: str):
      w3 = Web3(load_provider_from_uri(
          URI("http://localhost:8545")))
      gas_payer = w3.eth.account.from_key(priv_key)
      w3.eth.default_account = gas_payer.address
      w3.middleware_onion.add(
          construct_sign_and_send_raw_middleware(gas_payer),
          "construct_sign_and_send_raw_middleware",
      )
      return (w3, gas_payer)

  (w3, gas_payer) = get_w3_with_priv_key('YOUR_PRIVATE_KEY')
  escrow_client = EscrowClient(w3)

  escrow_address = "0x1234567890abcdef1234567890abcdef12345678"
  escrow_config = EscrowConfig(
      recording_oracle_address='0xabcdefabcdefabcdefabcdefabcdefabcdefabcdef',
      reputation_oracle_address='0xabcdefabcdefabcdefabcdefabcdefabcdefabcdef',
      exchange_oracle_address='0xabcdefabcdefabcdefabcdefabcdefabcdefabcdef',
      recording_oracle_fee=100,
      reputation_oracle_fee=100,
      exchange_oracle_fee=100,
      recording_oracle_url='https://example.com/recording',
      reputation_oracle_url='https://example.com/reputation',
      exchange_oracle_url='https://example.com/exchange',
      manifest_url='https://example.com/manifest',
      manifest_hash='0xabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef'
  )
  escrow_client.setup(
      escrow_address,
      escrow_config
  )
  ```
* **Return type:** `None`

#### store\_results(escrow\_address, url, hash, tx\_options=None)

Stores the results URL.

* **Parameters:**
  * **escrow\_address** (`str`) – Address of the escrow
  * **url** (`str`) – Results file URL
  * **hash** (`str`) – Results file hash
  * **tx\_options** (`Optional`\[`TxParams`]) – (Optional) Additional transaction parameters
* **Return type:** `None`
* **Returns:** None
* **Raises:** [**EscrowClientError**](#human_protocol_sdk.escrow.escrow_client.EscrowClientError) – If an error occurs while checking the parameters
* **Example:**

  ```python
  from eth_typing import URI
  from web3 import Web3
  from web3.middleware import construct_sign_and_send_raw_middleware
  from web3.providers.auto import load_provider_from_uri

  from human_protocol_sdk.escrow import EscrowClient

  def get_w3_with_priv_key(priv_key: str):
      w3 = Web3(load_provider_from_uri(URI("http://localhost:8545")))
      gas_payer = w3.eth.account.from_key(priv_key)
      w3.eth.default_account = gas_payer.address
      w3.middleware_onion.add(
          construct_sign_and_send_raw_middleware(gas_payer),
          "construct_sign_and_send_raw_middleware",
      )
      return (w3, gas_payer)

  (w3, gas_payer) = get_w3_with_priv_key('YOUR_PRIVATE_KEY')
  escrow_client = EscrowClient(w3)

  escrow_client.store_results(
      "0x62dD51230A30401C455c8398d06F85e4EaB6309f",
      "http://localhost/results.json",
      "b5dad76bf6772c0f07fd5e048f6e75a5f86ee079"
  )
  ```

#### withdraw(escrow\_address, token\_address, tx\_options=None)

Withdraws additional tokens in the escrow to the canceler.

* **Parameters:**
  * **escrow\_address** (`str`) – Address of the escrow to withdraw
  * **token\_address** (`str`) – Address of the token to withdraw
  * **tx\_options** (`Optional`\[`TxParams`]) – (Optional) Additional transaction parameters
* **Return type:** [`EscrowWithdraw`](#human_protocol_sdk.escrow.escrow_client.EscrowWithdraw)
* **Returns:** EscrowWithdraw: An instance of the EscrowWithdraw class containing details of the withdrawal transaction, including the transaction hash and the token address and amount withdrawn.
* **Raises:**
  * [**EscrowClientError**](#human_protocol_sdk.escrow.escrow_client.EscrowClientError) – If an error occurs while checking the parameters
  * [**EscrowClientError**](#human_protocol_sdk.escrow.escrow_client.EscrowClientError) – If the transfer event associated with the withdrawal is not found in the transaction logs
* **Example:**

  ```python
  from eth_typing import URI
  from web3 import Web3
  from web3.middleware import construct_sign_and_send_raw_middleware
  from web3.providers.auto import load_provider_from_uri

  from human_protocol_sdk.escrow import EscrowClient

  def get_w3_with_priv_key(priv_key: str):
      w3 = Web3(load_provider_from_uri(URI("http://localhost:8545")))
      gas_payer = w3.eth.account.from_key(priv_key)
      w3.eth.default_account = gas_payer.address
      w3.middleware_onion.add(
          construct_sign_and_send_raw_middleware(gas_payer),
          "construct_sign_and_send_raw_middleware",
      )
      return (w3, gas_payer)

  (w3, gas_payer) = get_w3_with_priv_key('YOUR_PRIVATE_KEY')
  escrow_client = EscrowClient(w3)

  escrow_cancel_data = escrow_client.withdraw(
      "0x62dD51230A30401C455c8398d06F85e4EaB6309f",
      "0x0376D26246Eb35FF4F9924cF13E6C05fd0bD7Fb4"
  )
  ```

### *exception* human\_protocol\_sdk.escrow\.escrow\_client.EscrowClientError

Bases: `Exception`

Raises when some error happens when interacting with escrow.

### *class* human\_protocol\_sdk.escrow\.escrow\_client.EscrowConfig(recording\_oracle\_address, reputation\_oracle\_address, exchange\_oracle\_address, recording\_oracle\_fee, reputation\_oracle\_fee, exchange\_oracle\_fee, manifest\_url, hash)

Bases: `object`

A class used to manage escrow parameters.

#### \_\_init\_\_(recording\_oracle\_address, reputation\_oracle\_address, exchange\_oracle\_address, recording\_oracle\_fee, reputation\_oracle\_fee, exchange\_oracle\_fee, manifest\_url, hash)

Initializes a Escrow instance.

* **Parameters:**
  * **recording\_oracle\_address** (`str`) – Address of the Recording Oracle
  * **reputation\_oracle\_address** (`str`) – Address of the Reputation Oracle
  * **recording\_oracle\_fee** (`Decimal`) – Fee percentage of the Recording Oracle
  * **reputation\_oracle\_fee** (`Decimal`) – Fee percentage of the Reputation Oracle
  * **manifest\_url** (`str`) – Manifest file url
  * **hash** (`str`) – Manifest file hash

### *class* human\_protocol\_sdk.escrow\.escrow\_client.EscrowWithdraw(tx\_hash, token\_address, amount\_withdrawn)

Bases: `object`

#### \_\_init\_\_(tx\_hash, token\_address, amount\_withdrawn)

Represents the result of an escrow cancellation transaction.

* **Parameters:**
  * **tx\_hash** (`str`) – The hash of the transaction associated with the escrow withdrawal.
  * **token\_address** (`str`) – The address of the token used for the withdrawal.
  * **amount\_withdrawn** (`any`) – The amount withdrawn from the escrow.
