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
Without Signer (For read operations only)
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 class used to manage escrow on the HUMAN network.
__init__(web3)
Initializes a Escrow instance.
Parameters: web3 (
Web3
) – The Web3 object
abort(escrow_address, tx_options=None)
Cancels the specified escrow, sends the balance to the canceler and selfdestructs the escrow contract.
Parameters:
escrow_address (
str
) – Address of the escrow to aborttx_options (
Optional
[TxParams
]) – (Optional) Additional transaction parameters
Return type:
None
Returns: None
Raises: EscrowClientError – If an error occurs while checking the parameters
Example:
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 escrowhandlers (
List
[str
]) – Array of trusted handler addressestx_options (
Optional
[TxParams
]) – (Optional) Additional transaction parameters
Return type:
None
Returns: None
Raises: EscrowClientError – If an error occurs while checking the parameters
Example:
bulk_payout(escrow_address, recipients, amounts, final_results_url, final_results_hash, txId, 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 escrowrecipients (
List
[str
]) – Array of recipient addressesamounts (
List
[Decimal
]) – Array of amounts the recipients will receivefinal_results_url (
str
) – Final results file urlfinal_results_hash (
str
) – Final results file hashtxId (
Decimal
) – Serial number of the bulkstx_options (
Optional
[TxParams
]) – (Optional) Additional transaction parameters
Return type:
None
Returns: None
Raises: EscrowClientError – If an error occurs while checking the parameters
Example:
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 canceltx_options (
Optional
[TxParams
]) – (Optional) Additional transaction parameters
Return type:
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 – If an error occurs while checking the parameters
EscrowClientError – If the transfer event associated with the cancellation is not found in the transaction logs
Example:
complete(escrow_address, tx_options=None)
Sets the status of an escrow to completed.
Parameters:
escrow_address (
str
) – Address of the escrow to completetx_options (
Optional
[TxParams
]) – (Optional) Additional transaction parameters
Return type:
None
Returns: None
Raises: EscrowClientError – If an error occurs while checking the parameters
Example:
create_and_setup_escrow(token_address, trusted_handlers, job_requester_id, escrow_config)
Creates and sets up an escrow.
Parameters:
token_address (
str
) – Token to use for pay outstrusted_handlers (
List
[str
]) – Array of addresses that can perform actions on the contractjob_requester_id (
str
) – The id of the job requesterescrow_config (
EscrowConfig
) – Object containing all the necessary information to setup an escrow
Return type:
str
Returns: The address of the escrow created
Raises: EscrowClientError – If an error occurs while checking the parameters
Example:
create_escrow(token_address, trusted_handlers, job_requester_id, tx_options=None)
Creates an escrow contract that uses the token passed to pay oracle fees and reward workers.
Parameters:
tokenAddress – The address of the token to use for payouts
trusted_handlers (
List
[str
]) – Array of addresses that can perform actions on the contractjob_requester_id (
str
) – The id of the job requestertx_options (
Optional
[TxParams
]) – (Optional) Additional transaction parameters
Return type:
str
Returns: The address of the escrow created
Raises: EscrowClientError – If an error occurs while checking the parameters
Example:
fund(escrow_address, amount, tx_options=None)
Adds funds to the escrow.
Parameters:
escrow_address (
str
) – Address of the escrow to setupamount (
Decimal
) – Amount to be added as fundstx_options (
Optional
[TxParams
]) – (Optional) Additional transaction parameters
Return type:
None
Returns: None
Raises: EscrowClientError – If an error occurs while checking the parameters
Example:
get_balance(escrow_address)
Gets the balance for a specified escrow address.
Parameters: escrow_address (
str
) – Address of the escrowReturn type:
Decimal
Returns: Value of the balance
Raises: EscrowClientError – If an error occurs while checking the parameters
Example:
get_exchange_oracle_address(escrow_address)
Gets the exchange oracle address of the escrow.
Parameters: escrow_address (
str
) – Address of the escrowReturn type:
str
Returns: Exchange oracle address
Raises: EscrowClientError – If an error occurs while checking the parameters
Example:
get_factory_address(escrow_address)
Gets the escrow factory address of the escrow.
Parameters: escrow_address (
str
) – Address of the escrowReturn type:
str
Returns: Escrow factory address
Raises: EscrowClientError – If an error occurs while checking the parameters
Example:
get_intermediate_results_url(escrow_address)
Gets the intermediate results file URL.
Parameters: escrow_address (
str
) – Address of the escrowReturn type:
str
Returns: Intermediate results file url
Raises: EscrowClientError – If an error occurs while checking the parameters
Example:
get_job_launcher_address(escrow_address)
Gets the job launcher address of the escrow.
Parameters: escrow_address (
str
) – Address of the escrowReturn type:
str
Returns: Job launcher address
Raises: EscrowClientError – If an error occurs while checking the parameters
Example:
get_manifest_hash(escrow_address)
Gets the manifest file hash.
Parameters: escrow_address (
str
) – Address of the escrowReturn type:
str
Returns: Manifest file hash
Raises: EscrowClientError – If an error occurs while checking the parameters
Example:
get_manifest_url(escrow_address)
Gets the manifest file URL.
Parameters: escrow_address (
str
) – Address of the escrowReturn str: Manifest file url
Raises: EscrowClientError – If an error occurs while checking the parameters
Example:
Return type:
str
get_recording_oracle_address(escrow_address)
Gets the recording oracle address of the escrow.
Parameters: escrow_address (
str
) – Address of the escrowReturn type:
str
Returns: Recording oracle address
Raises: EscrowClientError – If an error occurs while checking the parameters
Example:
get_reputation_oracle_address(escrow_address)
Gets the reputation oracle address of the escrow.
Parameters: escrow_address (
str
) – Address of the escrowReturn type:
str
Returns: Reputation oracle address
Raises: EscrowClientError – If an error occurs while checking the parameters
Example:
get_results_url(escrow_address)
Gets the results file URL.
Parameters: escrow_address (
str
) – Address of the escrowReturn type:
str
Returns: Results file url
Raises: EscrowClientError – If an error occurs while checking the parameters
Example:
get_status(escrow_address)
Gets the current status of the escrow.
Parameters: escrow_address (
str
) – Address of the escrowReturn type:
Status
Returns: Current escrow status
Raises: EscrowClientError – If an error occurs while checking the parameters
Example:
get_token_address(escrow_address)
Gets the address of the token used to fund the escrow.
Parameters: escrow_address (
str
) – Address of the escrowReturn type:
str
Returns: Address of the token
Raises: EscrowClientError – If an error occurs while checking the parameters
Example:
setup(escrow_address, escrow_config, tx_options=None)
Sets up the parameters of the escrow.
Parameters:
escrow_address (
str
) – Address of the escrow to setupescrow_config (
EscrowConfig
) – Object containing all the necessary information to setup an escrowtx_options (
Optional
[TxParams
]) – (Optional) Additional transaction parameters
Return type:
None
Returns: None
Raises: EscrowClientError – If an error occurs while checking the parameters
Example:
store_results(escrow_address, url, hash, tx_options=None)
Stores the results url.
Parameters:
escrow_address (
str
) – Address of the escrowurl (
str
) – Results file urlhash (
str
) – Results file hashtx_options (
Optional
[TxParams
]) – (Optional) Additional transaction parameters
Return type:
None
Returns: None
Raises: EscrowClientError – If an error occurs while checking the parameters
Example:
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 Oraclereputation_oracle_address (
str
) – Address of the Reputation Oraclerecording_oracle_fee (
Decimal
) – Fee percentage of the Recording Oraclereputation_oracle_fee (
Decimal
) – Fee percentage of the Reputation Oraclemanifest_url (
str
) – Manifest file urlhash (
str
) – Manifest file hash
Last updated