# Delegation

All delegation actions commands are below and detailed on their own section.

## List my delegation

> This endpoint is used to list the delegates voted for by the relevant PIRI address in the PIRI network. This process is also known as the staking mechanism in other networks. \
> \
> \*\*The reason for requesting the Private Key information for this endpoint is to ensure that only the owner of the relevant address can see the amount of frozen PIRI assets and which delegates the freezing process was performed for.\*\*

```json
{"openapi":"3.0.3","info":{"title":"Pirichain API","version":"1.1.0"},"tags":[{"name":"Delegation","description":"All delegation actions commands are below and detailed on their own section."}],"servers":[{"url":"https://core.pirichain.com","description":"Pirichain MainNet","variables":{}},{"url":"https://testnet.pirichain.com","description":"Pirichain TestNet","variables":{}},{"url":"https://{URL}","description":"You can only use https protocol for your custom environment.","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}},{"url":"http://{URL}","description":"Custom HTTP endpoint for development environment (not recommended for production).","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}}],"paths":{"/listMyDelegation":{"post":{"tags":["Delegation"],"summary":"List my delegation","description":"This endpoint is used to list the delegates voted for by the relevant PIRI address in the PIRI network. This process is also known as the staking mechanism in other networks. \n\n**The reason for requesting the Private Key information for this endpoint is to ensure that only the owner of the relevant address can see the amount of frozen PIRI assets and which delegates the freezing process was performed for.**","operationId":"listMyDelegation","requestBody":{"content":{"application/x-www-form-urlencoded":{"encoding":{},"schema":{"required":["delegationAddress","delegationPrivateKey"],"type":"object","properties":{"delegationAddress":{"type":"string","description":"PIRI Address"},"delegationPrivateKey":{"type":"string","description":"Private Key"}}}}},"required":true},"responses":{"200":{"description":"OK","content":{"application/json; charset=utf-8":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/listMyDelegation"}}}}}},"deprecated":false}}},"components":{"schemas":{"listMyDelegation":{"title":"listMyDelegation","required":["_id","delegationAddress","nodeAddress","frozenAmount","frozenDateTime","txHash","__v"],"type":"object","properties":{"_id":{"type":"string","description":"Delegation ID"},"delegationAddress":{"type":"string","description":"Delegator address"},"nodeAddress":{"type":"string","description":"Deputy node address"},"frozenAmount":{"type":"integer","format":"int32","description":"Frozen amount"},"frozenDateTime":{"type":"string","format":"date-time","description":"Frozen date and time"},"txHash":{"type":"string","description":"Transaction hash"},"__v":{"type":"integer","format":"int32","description":"Version key"}}}}}}
```

## Freeze coin

> This endpoint is used to vote for delegates on the PIRI network and to freeze the PIRIs in your wallet. Frozen PIRIs are non-transferable, but the freezing process can be canceled, and through the frozen PIRIs, daily PIRI rewards can be obtained from delegates.

```json
{"openapi":"3.0.3","info":{"title":"Pirichain API","version":"1.1.0"},"tags":[{"name":"Delegation","description":"All delegation actions commands are below and detailed on their own section."}],"servers":[{"url":"https://core.pirichain.com","description":"Pirichain MainNet","variables":{}},{"url":"https://testnet.pirichain.com","description":"Pirichain TestNet","variables":{}},{"url":"https://{URL}","description":"You can only use https protocol for your custom environment.","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}},{"url":"http://{URL}","description":"Custom HTTP endpoint for development environment (not recommended for production).","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}}],"paths":{"/freezeCoin":{"post":{"tags":["Delegation"],"summary":"Freeze coin","description":"This endpoint is used to vote for delegates on the PIRI network and to freeze the PIRIs in your wallet. Frozen PIRIs are non-transferable, but the freezing process can be canceled, and through the frozen PIRIs, daily PIRI rewards can be obtained from delegates.","operationId":"freezeCoin","requestBody":{"content":{"application/x-www-form-urlencoded":{"encoding":{},"schema":{"required":["delegationAddress","delegationPrivateKey","duptyAddress","amount"],"type":"object","properties":{"delegationAddress":{"type":"string","description":"Sender PIRI Address"},"delegationPrivateKey":{"type":"string","description":"Sender Private Key"},"duptyAddress":{"type":"string","description":"Delegate Address"},"amount":{"type":"number","description":"Amount to Freeze"}}}}},"required":true},"responses":{"200":{"description":"OK","content":{"application/json; charset=utf-8":{"schema":{"$ref":"#/components/schemas/freezeCoin"}}}}},"deprecated":false}}},"components":{"schemas":{"freezeCoin":{"title":"freezeCoin","required":["error","data","delegationID"],"type":"object","properties":{"error":{"type":"integer","format":"int32","description":"Error code (0 for success)"},"data":{"$ref":"#/components/schemas/TransactionResponse"},"delegationID":{"type":"string","description":"Delegation ID"}}},"TransactionResponse":{"title":"TransactionResponse","required":["error","tx","sign","timeStamp"],"type":"object","properties":{"error":{"type":"integer","format":"int32","description":"Error code (0 for success)"},"tx":{"type":"string","description":"Transaction hash"},"sign":{"type":"string","description":"Transaction signature"},"timeStamp":{"type":"integer","format":"int64","description":"Transaction timestamp"}}}}}}
```

## Unfreeze coin

> This endpoint is used to retrieve the frozen PIRI asset associated with the "freezeCoin" endpoint.

```json
{"openapi":"3.0.3","info":{"title":"Pirichain API","version":"1.1.0"},"tags":[{"name":"Delegation","description":"All delegation actions commands are below and detailed on their own section."}],"servers":[{"url":"https://core.pirichain.com","description":"Pirichain MainNet","variables":{}},{"url":"https://testnet.pirichain.com","description":"Pirichain TestNet","variables":{}},{"url":"https://{URL}","description":"You can only use https protocol for your custom environment.","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}},{"url":"http://{URL}","description":"Custom HTTP endpoint for development environment (not recommended for production).","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}}],"paths":{"/unFreezeCoin":{"post":{"tags":["Delegation"],"summary":"Unfreeze coin","description":"This endpoint is used to retrieve the frozen PIRI asset associated with the \"freezeCoin\" endpoint.","operationId":"unFreezeCoin","requestBody":{"content":{"application/x-www-form-urlencoded":{"encoding":{},"schema":{"required":["delegationAddress","delegationPrivateKey","nodeAddress","txHash"],"type":"object","properties":{"delegationAddress":{"type":"string","description":"Sender PIRI Address"},"delegationPrivateKey":{"type":"string","description":"Sender Private Key"},"nodeAddress":{"type":"string","description":"Delegate Address"},"txHash":{"type":"string","description":"Tx used during freezing"}}}}},"required":true},"responses":{"200":{"description":"OK","content":{"application/json; charset=utf-8":{"schema":{"$ref":"#/components/schemas/unFreezeCoin"}}}}},"deprecated":false}}},"components":{"schemas":{"unFreezeCoin":{"title":"unFreezeCoin","required":["error","tx","sign","timeStamp"],"type":"object","properties":{"error":{"type":"integer","format":"int32","description":"Error code (0 for success)"},"tx":{"type":"string","description":"Transaction hash"},"sign":{"type":"string","description":"Transaction signature"},"timeStamp":{"type":"integer","format":"int64","description":"Transaction timestamp"}}}}}}
```

## Join as deputy

> This endpoint is used to become a delegate on the PIRI network. There are some advantages to becoming a delegate, but there are also some points to be aware of.\
> \
> Before becoming a delegate, you need to:\
> \- Define the purpose of delegation and have knowledge about the delegation process.\
> \- Remember that delegation is a one-way process.\
> \- Ensure that you have the necessary information for delegation.\
> \- Make sure there is a balance of 11,000 PIRI or more in your wallet for delegation, excluding the commission fee.\
> \
> A delegated address gains the right to be selected. This means that different address owners can vote for this delegate and freeze PIRI for this delegate through the "freezeCoin" endpoint. A delegate with a freeze of 100,000 PIRI or more also assumes the role of a Producer Address. This information can be verified on the <https://piriscan.com/deputies> page.\
> \
> Another advantage of being a delegate is having a DVPA. DVPA stands for Domain Verified PIRI Address, which is a mechanism that allows an address to be associated with a domain. It facilitates a permanent and secure verification method, especially for commercial businesses, institutions, and government entities.

```json
{"openapi":"3.0.3","info":{"title":"Pirichain API","version":"1.1.0"},"tags":[{"name":"Delegation","description":"All delegation actions commands are below and detailed on their own section."}],"servers":[{"url":"https://core.pirichain.com","description":"Pirichain MainNet","variables":{}},{"url":"https://testnet.pirichain.com","description":"Pirichain TestNet","variables":{}},{"url":"https://{URL}","description":"You can only use https protocol for your custom environment.","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}},{"url":"http://{URL}","description":"Custom HTTP endpoint for development environment (not recommended for production).","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}}],"paths":{"/joinAsDeputy":{"post":{"tags":["Delegation"],"summary":"Join as deputy","description":"This endpoint is used to become a delegate on the PIRI network. There are some advantages to becoming a delegate, but there are also some points to be aware of.\n\nBefore becoming a delegate, you need to:\n- Define the purpose of delegation and have knowledge about the delegation process.\n- Remember that delegation is a one-way process.\n- Ensure that you have the necessary information for delegation.\n- Make sure there is a balance of 11,000 PIRI or more in your wallet for delegation, excluding the commission fee.\n\nA delegated address gains the right to be selected. This means that different address owners can vote for this delegate and freeze PIRI for this delegate through the \"freezeCoin\" endpoint. A delegate with a freeze of 100,000 PIRI or more also assumes the role of a Producer Address. This information can be verified on the https://piriscan.com/deputies page.\n\nAnother advantage of being a delegate is having a DVPA. DVPA stands for Domain Verified PIRI Address, which is a mechanism that allows an address to be associated with a domain. It facilitates a permanent and secure verification method, especially for commercial businesses, institutions, and government entities.","operationId":"joinAsDeputy","requestBody":{"content":{"application/x-www-form-urlencoded":{"encoding":{},"schema":{"required":["address","privateKey"],"type":"object","properties":{"address":{"type":"string","description":"PIRI Address"},"privateKey":{"type":"string","description":"Private Key"},"alias":{"type":"string","description":"Deputy Alias to give"},"website":{"type":"string","description":"**URL | Required for D.V.P.A. (Domain Verified PIRI Address)**"}}}}},"required":true},"responses":{"200":{"description":"OK","content":{"application/json; charset=utf-8":{"schema":{"$ref":"#/components/schemas/joinAsDeputy"}}}}},"deprecated":false}}},"components":{"schemas":{"joinAsDeputy":{"title":"joinAsDeputy","required":["error","data","tx"],"type":"object","properties":{"error":{"type":"integer","format":"int32","description":"Error code (0 for success)"},"data":{"type":"string","description":"Success message"},"tx":{"type":"string","description":"Transaction hash"}}}}}}
```

## Check deputy

> This endpoint is used to check whether a PIRI address is delegated or not.

```json
{"openapi":"3.0.3","info":{"title":"Pirichain API","version":"1.1.0"},"tags":[{"name":"Delegation","description":"All delegation actions commands are below and detailed on their own section."}],"servers":[{"url":"https://core.pirichain.com","description":"Pirichain MainNet","variables":{}},{"url":"https://testnet.pirichain.com","description":"Pirichain TestNet","variables":{}},{"url":"https://{URL}","description":"You can only use https protocol for your custom environment.","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}},{"url":"http://{URL}","description":"Custom HTTP endpoint for development environment (not recommended for production).","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}}],"paths":{"/checkDeputy":{"post":{"tags":["Delegation"],"summary":"Check deputy","description":"This endpoint is used to check whether a PIRI address is delegated or not.","operationId":"checkDeputy","requestBody":{"content":{"application/x-www-form-urlencoded":{"encoding":{},"schema":{"required":["address"],"type":"object","properties":{"address":{"type":"string","description":"PIRI Address"}}}}},"required":true},"responses":{"200":{"description":"OK","content":{"application/json; charset=utf-8":{"schema":{"type":"boolean"}}}}},"deprecated":false}}}}
```

## Verify address

> This endpoint is used to perform the DVPA (Domain Verified PIRI Address) verification for a delegated application address. It is important to note that when delegating an address, the "website" information must be provided. Otherwise, this endpoint will not be able to perform the necessary verification.

```json
{"openapi":"3.0.3","info":{"title":"Pirichain API","version":"1.1.0"},"tags":[{"name":"Delegation","description":"All delegation actions commands are below and detailed on their own section."}],"servers":[{"url":"https://core.pirichain.com","description":"Pirichain MainNet","variables":{}},{"url":"https://testnet.pirichain.com","description":"Pirichain TestNet","variables":{}},{"url":"https://{URL}","description":"You can only use https protocol for your custom environment.","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}},{"url":"http://{URL}","description":"Custom HTTP endpoint for development environment (not recommended for production).","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}}],"paths":{"/verifyAddress":{"post":{"tags":["Delegation"],"summary":"Verify address","description":"This endpoint is used to perform the DVPA (Domain Verified PIRI Address) verification for a delegated application address. It is important to note that when delegating an address, the \"website\" information must be provided. Otherwise, this endpoint will not be able to perform the necessary verification.","operationId":"verifyAddress","requestBody":{"content":{"application/x-www-form-urlencoded":{"encoding":{},"schema":{"required":["address"],"type":"object","properties":{"address":{"type":"string","description":"PIRI Address"}}}}},"required":true},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"boolean"}}}}},"deprecated":false}}}}
```

## List deputies

> This endpoint is used to list all delegates (delegated addresses) in the PIRI network.

```json
{"openapi":"3.0.3","info":{"title":"Pirichain API","version":"1.1.0"},"tags":[{"name":"Delegation","description":"All delegation actions commands are below and detailed on their own section."}],"servers":[{"url":"https://core.pirichain.com","description":"Pirichain MainNet","variables":{}},{"url":"https://testnet.pirichain.com","description":"Pirichain TestNet","variables":{}},{"url":"https://{URL}","description":"You can only use https protocol for your custom environment.","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}},{"url":"http://{URL}","description":"Custom HTTP endpoint for development environment (not recommended for production).","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}}],"paths":{"/listDeputies":{"post":{"tags":["Delegation"],"summary":"List deputies","description":"This endpoint is used to list all delegates (delegated addresses) in the PIRI network.","operationId":"listDeputies","responses":{"200":{"description":"OK","content":{"application/json; charset=utf-8":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/listDeputies"}}}}}},"deprecated":false}}},"components":{"schemas":{"listDeputies":{"title":"listDeputies","required":["verified","_id","depAddress","depAlias","depWebsite","frozenAmount","producedBlocks"],"type":"object","properties":{"verified":{"type":"boolean","description":"DVPA verification status"},"_id":{"type":"string","description":"Deputy ID"},"depAddress":{"type":"string","description":"Deputy address"},"depAlias":{"type":"string","description":"Deputy alias"},"depWebsite":{"type":"string","nullable":true,"description":"Deputy website"},"frozenAmount":{"type":"number","description":"Total frozen amount"},"producedBlocks":{"type":"number","description":"Number of produced blocks"}}}}}}
```

## Get my reward quantity

> This endpoint returns the total earnings obtained from frozen PIRI amounts for delegates by the respective address.

```json
{"openapi":"3.0.3","info":{"title":"Pirichain API","version":"1.1.0"},"tags":[{"name":"Delegation","description":"All delegation actions commands are below and detailed on their own section."}],"servers":[{"url":"https://core.pirichain.com","description":"Pirichain MainNet","variables":{}},{"url":"https://testnet.pirichain.com","description":"Pirichain TestNet","variables":{}},{"url":"https://{URL}","description":"You can only use https protocol for your custom environment.","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}},{"url":"http://{URL}","description":"Custom HTTP endpoint for development environment (not recommended for production).","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}}],"paths":{"/getMyRewardQuantity":{"post":{"tags":["Delegation"],"summary":"Get my reward quantity","description":"This endpoint returns the total earnings obtained from frozen PIRI amounts for delegates by the respective address.","operationId":"getMyRewardQuantity","requestBody":{"content":{"application/x-www-form-urlencoded":{"encoding":{},"schema":{"required":["base58","privateKey"],"type":"object","properties":{"base58":{"type":"string","description":"PIRI Address"},"privateKey":{"type":"string","description":"Private Key"}}}}},"required":true},"responses":{"200":{"description":"OK","content":{"application/json; charset=utf-8":{"schema":{"$ref":"#/components/schemas/getMyRewardQuantity"}}}}},"deprecated":false}}},"components":{"schemas":{"getMyRewardQuantity":{"title":"getMyRewardQuantity","required":["error","rewardAmount"],"type":"object","properties":{"error":{"type":"integer","format":"int32","description":"Error code (0 for success)"},"rewardAmount":{"type":"number","description":"Total reward amount"}}}}}}
```

## Claim my rewards

> This endpoint is used to collect earnings obtained from delegates for the specified address.

```json
{"openapi":"3.0.3","info":{"title":"Pirichain API","version":"1.1.0"},"tags":[{"name":"Delegation","description":"All delegation actions commands are below and detailed on their own section."}],"servers":[{"url":"https://core.pirichain.com","description":"Pirichain MainNet","variables":{}},{"url":"https://testnet.pirichain.com","description":"Pirichain TestNet","variables":{}},{"url":"https://{URL}","description":"You can only use https protocol for your custom environment.","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}},{"url":"http://{URL}","description":"Custom HTTP endpoint for development environment (not recommended for production).","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}}],"paths":{"/claimMyRewards":{"post":{"tags":["Delegation"],"summary":"Claim my rewards","description":"This endpoint is used to collect earnings obtained from delegates for the specified address.","operationId":"claimMyRewards","requestBody":{"content":{"application/x-www-form-urlencoded":{"encoding":{},"schema":{"required":["address","privateKey"],"type":"object","properties":{"address":{"type":"string","description":"PIRI Address"},"privateKey":{"type":"string","description":"Private Key"}}}}},"required":true},"responses":{"200":{"description":"OK","content":{"application/json; charset=utf-8":{"schema":{"$ref":"#/components/schemas/claimMyRewards"}}}}},"deprecated":false}}},"components":{"schemas":{"claimMyRewards":{"title":"claimMyRewards","required":["error","tx","sign","timeStamp"],"type":"object","properties":{"error":{"type":"integer","format":"int32","description":"Error code (0 for success)"},"tx":{"type":"string","description":"Transaction hash"},"sign":{"type":"string","description":"Transaction signature"},"timeStamp":{"type":"integer","format":"int64","description":"Transaction timestamp"}}}}}}
```

## List delegation top N

> This endpoint provides a list of delegates within the PIRI network who have a frozen PIRI amount of 100,000 or more.

```json
{"openapi":"3.0.3","info":{"title":"Pirichain API","version":"1.1.0"},"tags":[{"name":"Delegation","description":"All delegation actions commands are below and detailed on their own section."}],"servers":[{"url":"https://core.pirichain.com","description":"Pirichain MainNet","variables":{}},{"url":"https://testnet.pirichain.com","description":"Pirichain TestNet","variables":{}},{"url":"https://{URL}","description":"You can only use https protocol for your custom environment.","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}},{"url":"http://{URL}","description":"Custom HTTP endpoint for development environment (not recommended for production).","variables":{"URL":{"default":"custom.network","description":"You can enter your custom endpoint which belong to Pirichain Network"}}}],"paths":{"/listDelegationTopN":{"post":{"tags":["Delegation"],"summary":"List delegation top N","description":"This endpoint provides a list of delegates within the PIRI network who have a frozen PIRI amount of 100,000 or more.","operationId":"listDelegationTopN","responses":{"200":{"description":"OK","content":{"application/json; charset=utf-8":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/listDelegationTopN"}}}}}},"deprecated":false}}},"components":{"schemas":{"listDelegationTopN":{"title":"listDelegationTopN","required":["_id","totalFrozen"],"type":"object","properties":{"_id":{"type":"string","description":"Deputy address"},"totalFrozen":{"type":"integer","format":"int32","description":"Total frozen amount"}}}}}}
```
