# Basic crypto operations

{% hint style="warning" %}
Every request listed on this page requires [authorization](https://docs.0xpay.app/public-api/endpoints/broken-reference) to be successfully completed.&#x20;
{% endhint %}

## Create permanent deposit address

<mark style="color:green;">`POST`</mark> `https://public.api.0xpay.app/merchants/addresses`

As said [previously](https://docs.0xpay.app/integration-cookbook/receive-assets#receiving-addresses), you can generate new deposit addresses with `receiving addresses` feature. **For BEP20 & ERC20 networks:** on creation, one wallet address will be generated and assigned for both networks, and monitored for incoming transactions.

**Deposit Updates:** After a receiving address is created on a dedicated blockchain, 0xpay will [notify you about incoming transactions](https://docs.0xpay.app/notifications#replenishment) for all the assets supported on this blockchain.

#### Request Body

| Name                                         | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| -------------------------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| meta                                         | string | metadata, write your id here to catch it back later with a notification                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| blockchain<mark style="color:red;">\*</mark> | string | available values you can find [here](https://docs.0xpay.app/general/networks-and-assets#blockchains) ("API value" column)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| target                                       | object | <p><code>ticker: string</code> - the currency to which we will try to exchange all funds deposited to this address funds if <code>target.ticker == amount.ticker</code> no exchange will happen</p><p><code>address: string</code> - the address, to which we will withdraw funds in the currency specified in <code>target.ticker</code> </p><p><code>blockchain: string</code> - network in which withdrawal will be made, this field is required if <code>target.address</code> is provided, available values you can find <a href="../../../general/networks-and-assets#blockchains">here</a> ("API value" column) </p> |

{% tabs %}
{% tab title="200: OK Address generated successfully" %}

```javascript
{
  "address":  "0x8EB871bbB6F754a04bCa23881A7D25A30aAD3f23",
  "meta":  "some-user-id",
  "blockchain":  "ETHEREUM"
}
```

{% endtab %}
{% endtabs %}

## Create rotating deposit address

<mark style="color:green;">`POST`</mark> `https://public.api.0xpay.app/merchants/rotating-addresses`

As said [previously](https://docs.0xpay.app/integration-cookbook/receive-assets#receiving-addresses), you can generate new deposit addresses with `receiving addresses` feature.&#x20;

An address will be active until the first incoming transaction is received, or for a specified timeframe (set with `duration` parameter)

**Deposit Updates:** After a receiving address is created on a dedicated blockchain, 0xpay will [notify you about an incoming transaction](https://docs.0xpay.app/notifications#replenishment) for all the assets supported on this blockchain.

#### Request Body

| Name                                         | Type   | Description                                                                                                                                                                                                                               |
| -------------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| meta                                         | string | metadata, write your id here to catch it back later with a notification                                                                                                                                                                   |
| blockchain<mark style="color:red;">\*</mark> | string | available values you can find [here](https://docs.0xpay.app/general/networks-and-assets#blockchains) ("API value" column)                                                                                                                 |
| duration                                     | number | <p>timeframe for which the address will be active. </p><p>(min: 1000 ms; max: 259200000 ms). By default, <em>duration</em> will be set to 86400000ms.  </p>                                                                               |
| durationAfterReplenishment                   | number | <p>additional timeframe after the first replenishment transaction, during which the address will still stay active for deposits. </p><p>(min: 1000 ms; max: 86400000 ms). By default, <em>duration</em> will be set to 7200000 ms.   </p> |

{% tabs %}
{% tab title="200: OK Address generated successfully" %}

```javascript
{
  "meta":  "some-user-id",
  "address":  "0x8EB871bbB6F754a04bCa23881A7D25A30aAD3f23",
  "duration": 16508758624753,
}
```

{% endtab %}
{% endtabs %}

## Send cryptocurrency

<mark style="color:green;">`POST`</mark> `https://public.api.0xpay.app/merchants/withdrawals/crypto`

Creates an outgoing cryptocurrency transaction. 0xpay API will produce [notifications](https://docs.0xpay.app/notifications#withdrawal) according to status updates on your withdrawal.

#### Request Body

| Name                                         | Type   | Description                                                                                                                                                                                            |
| -------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| ticker<mark style="color:red;">\*</mark>     | string | find values with "List available tickers" request                                                                                                                                                      |
| to<mark style="color:red;">\*</mark>         | string | Destination wallet address                                                                                                                                                                             |
| blockchain<mark style="color:red;">\*</mark> | string | available values you can find [here](https://docs.0xpay.app/general/networks-and-assets#blockchains) ("API value" column)                                                                              |
| amount<mark style="color:red;">\*</mark>     | string | amount in decimal format                                                                                                                                                                               |
| fee                                          | string | you can specify withdrawal fees that have to be greater than the actual fee, which can be useful for better fee calculation options on your side. If not the specified – fee will be set automatically |
| localId                                      | string | if was specified error will be thrown if not unique, can be useful on your side to avoid the [double-spend](https://en.wikipedia.org/wiki/Double-spending) issue                                       |
| meta                                         | string | *your metadata* that will be passed along to you later with a notification                                                                                                                             |

{% tabs %}
{% tab title="200: OK Transaction created & sent to processing" %}
{% code overflow="wrap" %}

```javascript
{
    "id": "123e4567-e89b-12d3-a456-426614174000" //internal ID has been assigned to the tx
}
```

{% endcode %}
{% endtab %}

{% tab title="400: Bad Request One of the following errors occured:" %}
{% code title="Error codes:" %}

```json
//List of error codes:
//0 - Local id already placed 
//1 – Not enough balance
//2 – Fee less than required
//3 – Withdraw amount too low
//4 – Merchant not found
//5 – Balance not found
//6 – You don't have permission for this

{
    code: 0 
    description: "Local id already placed"
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Withdrawal fee

<mark style="color:blue;">`GET`</mark> `https://public.api.0xpay.app/merchants/withdrawals/crypto/fee`

This method is used to get a fee for sending a desired *amount of assets* (`ticker`) on a chosen *blockchain*. Learn how fees work [here](https://docs.0xpay.app/general/transaction-fees)

#### Request Body

| Name                                         | Type   | Description                                                                                                               |
| -------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------- |
| ticker<mark style="color:red;">\*</mark>     | string | find values with "List all supported assets" request                                                                      |
| blockchain<mark style="color:red;">\*</mark> | string | available values you can find [here](https://docs.0xpay.app/general/networks-and-assets#blockchains) ("API value" column) |
| amount<mark style="color:red;">\*</mark>     | string | amount in decimal format                                                                                                  |
| address                                      | string | <p>destination wallet address<br>(fill in to check if tx is an internal zero-fee transfer)</p>                            |

{% tabs %}
{% tab title="200: OK Fee value is calculated successfully" %}
{% code overflow="wrap" %}

```javascript
{
  "value":  "0.1" //decimal fee value
}
```

{% endcode %}
{% endtab %}

{% tab title="400: Bad Request Asset is not supported" %}
{% code title="Error codes:" overflow="wrap" %}

```json
{
    code: 0 
    description: "Asset not supported"
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Replenishment risk score

<mark style="color:blue;">`GET`</mark> `https://public.api.0xpay.app/merchants/replenishment/crypto/:id/compliance`

This method is used to get replenishment risk score by it's id.

We recommend you to check risk score in 5 minutes after transaction is being broadcasted to blockchain.&#x20;

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "url": "https://yourreport.com",
    "signals": {
        "atm": 0,
        "ico": 0,
        "scam": 0,
        "miner": 0,
        "mixer": 0,
        "other": 0,
        "ransom": 0,
        "wallet": 0,
        "payment": 0,
        "exchange": 0,
        "gambling": 0,
        "sanctions": 0,
        "fraud_shop": 0,
        "dark_market": 0,
        "marketplace": 0,
        "dark_service": 0,
        "p2p_exchange": 0,
        "stolen_coins": 0,
        "seized_assets": 0,
        "risky_exchange": 0,
        "smart_contract": 0,
        "illegal_service": 0,
        "liquidity_pools": 0,
        "online_pharmacy": 0,
        "unnamed_service": 0,
        "lending_contract": 0,
        "protocol_privacy": 0,
        "special_measures": 0,
        "illicit_actor_org": 0,
        "merchant_services": 0,
        "child_exploitation": 0,
        "enforcement_action": 0,
        "exchange_fraudulent": 0,
        "exchange_mlrisk_low": 0,
        "terrorism_financing": 0,
        "exchange_mlrisk_high": 0,
        "token_smart_contract": 0,
        "high_risk_jurisdiction": 0,
        "p2p_exchange_mlrisk_low": 0,
        "exchange_mlrisk_moderate": 0,
        "exchange_mlrisk_veryhigh": 0,
        "p2p_exchange_mlrisk_high": 0,
        "infrastructure_as_a_service": 0,
        "decentralized_exchange_contract": 0
    },
    "riskScore": 0,
    "timestamp": 1686991713000
}
```

{% endtab %}
{% endtabs %}

## Withdrawal risk score

<mark style="color:blue;">`GET`</mark> `https://public.api.0xpay.app/merchants/withdrawals/crypto/:id/compliance`

This method is used to get withdrawal risk-score by it's id.

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "url": "https://yourreport.com",
    "signals": {
        "atm": 0,
        "ico": 0,
        "scam": 0,
        "miner": 0,
        "mixer": 0,
        "other": 0,
        "ransom": 0,
        "wallet": 0,
        "payment": 0,
        "exchange": 0,
        "gambling": 0,
        "sanctions": 0,
        "fraud_shop": 0,
        "dark_market": 0,
        "marketplace": 0,
        "dark_service": 0,
        "p2p_exchange": 0,
        "stolen_coins": 0,
        "seized_assets": 0,
        "risky_exchange": 0,
        "smart_contract": 0,
        "illegal_service": 0,
        "liquidity_pools": 0,
        "online_pharmacy": 0,
        "unnamed_service": 0,
        "lending_contract": 0,
        "protocol_privacy": 0,
        "special_measures": 0,
        "illicit_actor_org": 0,
        "merchant_services": 0,
        "child_exploitation": 0,
        "enforcement_action": 0,
        "exchange_fraudulent": 0,
        "exchange_mlrisk_low": 0,
        "terrorism_financing": 0,
        "exchange_mlrisk_high": 0,
        "token_smart_contract": 0,
        "high_risk_jurisdiction": 0,
        "p2p_exchange_mlrisk_low": 0,
        "exchange_mlrisk_moderate": 0,
        "exchange_mlrisk_veryhigh": 0,
        "p2p_exchange_mlrisk_high": 0,
        "infrastructure_as_a_service": 0,
        "decentralized_exchange_contract": 0
    },
    "riskScore": 0,
    "timestamp": 1686991713000
}
```

{% endtab %}
{% endtabs %}

## Available crypto assets

<mark style="color:blue;">`GET`</mark> `https://public.api.0xpay.app/merchants/assets/crypto/`

This method is used to fetch all available crypto assets of your merchant. You can learn about available assets [here](https://docs.0xpay.app/general/networks-and-assets).

{% tabs %}
{% tab title="200: OK Fee value is calculated successfully" %}
{% code overflow="wrap" %}

```javascript
//In response, you'll get an Array of all assets with their ticker , name, price, and blockchain network: 
[
    {
        "name": "Bitcoin", 
        "ticker": "BTC",
        "blockchains": [
            "BITCOIN"
        ],
        "price": {
            "value": "29931",
            "ticker": "USD"
        }
    },
    {
        "name": "Ethereum",
        "ticker": "ETH",
        "blockchains": [
            "ETHEREUM"
        ],
        "price": {
            "value": "1797.26",
            "ticker": "USD"
        }
    },
    {
        "name": "BNB",
        "ticker": "BNB",
        "blockchains": [
            "BINANCE_SMART_CHAIN"
        ],
        "price": {
            "value": "301.54",
            "ticker": "USD"
        }
    }
 ]
```

{% endcode %}
{% endtab %}
{% endtabs %}
