> For the complete documentation index, see [llms.txt](https://docs.idosgames.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.idosgames.com/api/api-v1/crypto-wallet.md).

# Crypto Wallet

This endpoint is used to perform various blockchain transactions, such as token and NFT transactions, to and from the game and users' crypto wallets.

#### URL

```
https://api.idosgames.com/api/{titleTemplateId}/{titleId}/Client/CryptoWallet/Transaction  
```

#### Method

* POST

#### Route Parameters

* `titleTemplateId` (string): The template ID of the title.
* `titleId` (string): The ID of the title.

#### Request Body (JSON)

```json
{  
    "WebAppLink": "string",  
    "UsageTime": "int",  
    "ClientSessionTicket": "string",  
    "EntityToken": "string",  
    "UserID": "string",  
    "TransactionType": "string",  
    "TransactionDirection": "string",  
    "ChainID": "string",  
    "TransactionHash": "string",  
    "VirtualCurrencyID": "string",  
    "Amount": "string",  
    "WalletAddress": "string",  
    "SkinID": "string"  
}  
```

#### Responses

* `200 OK`: Successful operation. Returns the transaction status.
* `400 Bad Request`: Incorrect request parameters or validation error. Possible messages:
  * `INVALID_REQUEST_ARGS`
  * `TITLEID_INCORRECT`
  * `INCORRECT_CHAIN_ID`
  * `INCORRECT_TRANSACTION_TYPE`
  * `INCORRECT_TRANSACTION_DIRECTION`

## **MakeTokenTransactionToGame**

**Description**: This action handles the transfer of tokens to the game from the user's wallet.

* **Route**: `/Transaction`
* **Method**: POST

**Request Parameters**:

```json
{  
    "WebAppLink": "string",  
    "UsageTime": "int",  
    "ClientSessionTicket": "string",  
    "EntityToken": "string",  
    "UserID": "string",  
    "TransactionType": "Token",  
    "TransactionDirection": "Game",  
    "ChainID": "string",  
    "TransactionHash": "string"  
}  
```

**Responses**

* `200 OK`: Transaction successful. Returns a success message with the transaction hash.
* `400 Bad Request`: Incorrect request parameters. Possible errors include `INVALID_REQUEST_ARGS`, `INCORRECT_HASH`, `INCORRECT_TRANSACTION`, `TRANSACTION_HASH_ALREADY_USED`, `INCORRECT_TOKEN_ID`, and `FAILED_TO_SAVE_TO_DATABASE`.

**Example Usage**:

```javascript
fetch('https://api.idosgames.com/api/{titleTemplateId}/{titleId}/Client/CryptoWallet/Transaction', {  
    method: 'POST',  
    headers: {  
        'Content-Type': 'application/json'  
    },  
    body: JSON.stringify({  
        WebAppLink: 'https://example.com/?titleID=0',  
        UsageTime: 120,  
        ClientSessionTicket: 'valid-session-ticket',  
        EntityToken: 'valid-entity-token',  
        UserID: 'user-id',  
        TransactionType: 'Token',  
        TransactionDirection: 'Game',  
        ChainID: '1',  
        TransactionHash: 'hash-value'  
    })  
})  
.then(response => response.json())  
.then(data => console.log(data))  
.catch(error => console.error('Error:', error));  
```

***

## **MakeTokenTransactionToUsersCryptoWallet**

**Description**: This action handles the transfer of tokens to the user's wallet from the game.

* **Route**: `/Transaction`
* **Method**: POST

**Request Parameters**:

```json
{  
    "WebAppLink": "string",  
    "UsageTime": "int",  
    "ClientSessionTicket": "string",  
    "EntityToken": "string",  
    "UserID": "string",  
    "TransactionType": "Token",  
    "TransactionDirection": "UsersCryptoWallet",  
    "ChainID": "string",  
    "VirtualCurrencyID": "string",  
    "Amount": "string",  
    "WalletAddress": "string"  
}  
```

**Responses**

* `200 OK`: Transaction successful. Returns a success message with the transaction hash.
* `400 Bad Request`: Incorrect request parameters. Possible errors include `INVALID_REQUEST_ARGS`, `INCORRECT_VIRTUAL_CURRENCY_ID`, `INCORRECT_AMOUNT`, `INCORRECT_WALLET_ADDRESS`, `FAILED_TO_MODIFY_VIRTUAL_CURRENCY`, `NOT_ENOUGH_FUNDS`, `ALL_RESOURCES_ARE_BUSY`, and `FAILED_TO_SAVE_TO_DATABASE`.

**Example Usage**:

```javascript
fetch('https://api.idosgames.com/api/{titleTemplateId}/{titleId}/Client/CryptoWallet/Transaction', {  
    method: 'POST',  
    headers: {  
        'Content-Type': 'application/json'  
    },  
    body: JSON.stringify({  
        WebAppLink: 'https://example.com/?titleID=0',  
        UsageTime: 120,  
        ClientSessionTicket: 'valid-session-ticket',  
        EntityToken: 'valid-entity-token',  
        UserID: 'user-id',  
        TransactionType: 'Token',  
        TransactionDirection: 'UsersCryptoWallet',  
        ChainID: '1',  
        VirtualCurrencyID: 'VCID',  
        Amount: '100',  
        WalletAddress: 'wallet-address'  
    })  
})  
.then(response => response.json())  
.then(data => console.log(data))  
.catch(error => console.error('Error:', error));  
```

***

## **MakeNFTTransactionToGame**

**Description**: This action handles the transfer of NFTs to the game from the user's wallet.

* **Route**: `/Transaction`
* **Method**: POST

**Request Parameters**:

```json
{  
    "WebAppLink": "string",  
    "UsageTime": "int",  
    "ClientSessionTicket": "string",  
    "EntityToken": "string",  
    "UserID": "string",  
    "TransactionType": "NFT",  
    "TransactionDirection": "Game",  
    "ChainID": "string",  
    "TransactionHash": "string"  
}  
```

**Responses**

* `200 OK`: Transaction successful. Returns a success message with the transaction hash.
* `400 Bad Request`: Incorrect request parameters. Possible errors include `INVALID_REQUEST_ARGS`, `INCORRECT_HASH`, `INCORRECT_TRANSACTION`, `TRANSACTION_HASH_ALREADY_USED`, `INCORRECT_NFT_ID`, `FAILED_TO_SAVE_TO_DATABASE`, and `FAILED_TO_GRANT_ITEMS`.

**Example Usage**:

```javascript
fetch('https://api.idosgames.com/api/{titleTemplateId}/{titleId}/Client/CryptoWallet/Transaction', {  
    method: 'POST',  
    headers: {  
        'Content-Type': 'application/json'  
    },  
    body: JSON.stringify({  
        WebAppLink: 'https://example.com/?titleID=0',  
        UsageTime: 120,  
        ClientSessionTicket: 'valid-session-ticket',  
        EntityToken: 'valid-entity-token',  
        UserID: 'user-id',  
        TransactionType: 'NFT',  
        TransactionDirection: 'Game',  
        ChainID: '1',  
        TransactionHash: 'hash-value'  
    })  
})  
.then(response => response.json())  
.then(data => console.log(data))  
.catch(error => console.error('Error:', error));  
```

***

## **MakeNFTTransactionToUsersCryptoWallet**

**Description**: This action handles the transfer of NFTs to the user's wallet from the game.

* **Route**: `/Transaction`
* **Method**: POST

**Request Parameters**:

```json
{  
    "WebAppLink": "string",  
    "UsageTime": "int",  
    "ClientSessionTicket": "string",  
    "EntityToken": "string",  
    "UserID": "string",  
    "TransactionType": "NFT",  
    "TransactionDirection": "UsersCryptoWallet",  
    "ChainID": "string",  
    "SkinID": "string",  
    "Amount": "string",  
    "WalletAddress": "string"  
}  
```

**Responses**

* `200 OK`: Transaction successful. Returns a success message with the transaction hash.
* `400 Bad Request`: Incorrect request parameters. Possible errors include `INVALID_REQUEST_ARGS`, `INCORRECT_SKIN_ID`, `INCORRECT_AMOUNT`, `INCORRECT_WALLET_ADDRESS`, `FAILED_TO_CONSUME_ITEMS`, `FAILED_TO_MODIFY_VIRTUAL_CURRENCY`, `NOT_ENOUGH_FUNDS`, `ALL_RESOURCES_ARE_BUSY`, and `FAILED_TO_SAVE_TO_DATABASE`.

**Example Usage**:

```javascript
fetch('https://api.idosgames.com/api/{titleTemplateId}/{titleId}/Client/CryptoWallet/Transaction', {  
    method: 'POST',  
    headers: {  
        'Content-Type': 'application/json'  
    },  
    body: JSON.stringify({  
        WebAppLink: 'https://example.com/?titleID=0',  
        UsageTime: 120,  
        ClientSessionTicket: 'valid-session-ticket',  
        EntityToken: 'valid-entity-token',  
          
        UserID: 'user-id',  
        TransactionType: 'NFT',  
        TransactionDirection: 'UsersCryptoWallet',  
        ChainID: '1',  
        SkinID: 'skin-id',  
        Amount: '1',  
        WalletAddress: 'wallet-address'  
    })  
})  
.then(response => response.json())  
.then(data => console.log(data))  
.catch(error => console.error('Error:', error));  
```

***
