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

# Wallet

## Wallet Exists?

<mark style="color:blue;">`GET`</mark> `http://127.0.0.1:31567/wallet/exists`

Check if wallet has already been created / imported.\
\
Used for building a rich wallet client UI.

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

```javascript
true
```

{% endtab %}
{% endtabs %}

## Public Address

<mark style="color:blue;">`GET`</mark> `http://127.0.0.1:31567/wallet/address`

Fetch your public key

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

```javascript
"tp1q7n4l3dldcv69wfyqm32mpkwvf56q5kjdv7ma5p2668z05ljcv2gsq3ke4q"
```

{% endtab %}
{% endtabs %}

## Asset Balances

<mark style="color:blue;">`GET`</mark> `http://127.0.0.1:31567/wallet/balance`

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

```javascript
[
    {
        "asset": "asset",
        "balance": 2147483649
    }
]
```

{% endtab %}
{% endtabs %}

## Received by address

<mark style="color:blue;">`GET`</mark> `http://127.0.0.1:31567/wallet/receivedbyaddress`

Transaction received by address

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

```json
[
    {
        "address": "tzn1q7fnh47xftwr2zpxtpxepf022l9u5k0kusahactcn099vlumxy58s4kzzx6",
        "asset": "00",
        "amount": "417971197827512"
    }
]
```

{% endtab %}
{% endtabs %}

## Address Output

<mark style="color:blue;">`GET`</mark> `http://127.0.0.1:31567/wallet/addressoutputs`

#### Query Parameters

| Name                                      | Type   | Description |
| ----------------------------------------- | ------ | ----------- |
| address<mark style="color:red;">\*</mark> | string |             |

{% tabs %}
{% tab title="200 List of address outputs" %}

```json
[
    {
        "outpoint": {
            "txHash": "004ea75d74f2e3ac34634b43c979092b8eb04f9de544b905e5cb8ae8b316b120",
            "index": 2
        },
        "asset": "00",
        "amount": "187500000",
        "confirmations": 266423,
        "spent": true
    }
]
```

{% endtab %}

{% tab title="400 Error" %}

```
address is missing
```

{% endtab %}
{% endtabs %}

## Address Balance

<mark style="color:blue;">`GET`</mark> `http://127.0.0.1:31567/wallet/addressbalance`

#### Path Parameters

| Name                                      | Type   | Description                              |
| ----------------------------------------- | ------ | ---------------------------------------- |
| address<mark style="color:red;">\*</mark> | string | Address you want to check the balance of |

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

```json
[
    {
        "outpoint": {
            "txHash": "004ea75d74f2e3ac34634b43c979092b8eb04f9de544b905e5cb8ae8b316b120",
            "index": 2
        },
        "asset": "00",
        "amount": "187500000",
        "confirmations": 266423,
        "spent": true
    },
    {
        "outpoint": {
            "txHash": "0052a006747ec056de0bf3bc044983a370d6ff5aa4659ebbbe45e03633d21843",
            "index": 2
        },
        "asset": "00",
        "amount": "1000000000",
        "confirmations": 380819,
        "spent": true
    }
]

```

{% endtab %}

{% tab title="400: Bad Request " %}

```
address is missing
```

{% endtab %}
{% endtabs %}

## Remove Wallet

<mark style="color:blue;">`GET`</mark> `http://127.0.0.1:31567/wallet/remove`

Remove wallet

#### Request Body

| Name     | Type   | Description     |
| -------- | ------ | --------------- |
| password | string | wallet password |

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

```
```

{% endtab %}
{% endtabs %}

## Zen Public Key (XPUB)

<mark style="color:blue;">`GET`</mark> `http://127.0.0.1:31567/wallet/zenpublickey`

Return the Zen public key (XPUB)

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

```json
tpubDDBhhX7DRpypAPZZhVMEtnyzJJrCRgQGSzNwgpqxTxXHdvedtkE2pjjVbY5NHvY6FLL2c8mzQcQnxK4s4pjt5BS6cBUHvan5y6NRtHft2tp
```

{% endtab %}
{% endtabs %}

## Resync

<mark style="color:blue;">`GET`</mark> `http://127.0.0.1:31567/wallet/resync`

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

```
```

{% endtab %}
{% endtabs %}

## Transaction Count

<mark style="color:blue;">`GET`</mark> `http://127.0.0.1:31567/wallet/transactioncount`

Get transaction count (used for pagination)

#### Path Parameters

| Name | Type   | Description |
| ---- | ------ | ----------- |
|      | string |             |

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

```
25
```

{% endtab %}
{% endtabs %}

## Transaction History

<mark style="color:blue;">`GET`</mark> `http://127.0.0.1:31567/wallet/transactions`

Retreive the transaction history

#### Request Body

| Name | Type   | Description |
| ---- | ------ | ----------- |
| take | number |             |
| skip | number |             |

{% tabs %}
{% tab title="200 An array of tx objects, where each transaction can have a single or multiple tx deltas or incoming or outgoing assets." %}

```javascript
[
    {
        "txHash": "txHash",
        "asset": "00",
        "amount": 0,
        "confirmations": "someConfrimation"
    }
]
```

{% endtab %}

{% tab title="400 Remember to add the parameters skip and take" %}

```
Invalid input
```

{% endtab %}
{% endtabs %}

## Import Wallet

<mark style="color:green;">`POST`</mark> `http://127.0.0.1:31567/wallet/import`

#### Path Parameters

| Name  | Type  | Description                              |
| ----- | ----- | ---------------------------------------- |
| words | array | A list of 12 or 24 bip39 compliant words |

#### Request Body

| Name     | Type   | Description                                |
| -------- | ------ | ------------------------------------------ |
| password | string | A password to encrypt your mnemonic phrase |

{% tabs %}
{% tab title="200 The account was imported correctly" %}

```javascript
```

{% endtab %}

{% tab title="400 Account already exist" %}

```
```

{% endtab %}
{% endtabs %}

## Public Key

<mark style="color:green;">`POST`</mark> `http://127.0.0.1:31567/wallet/publickey`

Get the public key paired with the path

#### Request Body

| Name     | Type   | Description           |
| -------- | ------ | --------------------- |
| password | string | wallet password       |
| path     | string | bit44 derivative path |

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

```
0278e2befe3063f02b01d1f7c08abae7d0669b58be6691baac94e67ad52c540f22
```

{% endtab %}
{% endtabs %}

## Send Transaction

<mark style="color:green;">`POST`</mark> `http://127.0.0.1:31567/wallet/send`

Send a transaction to another regular wallet address

#### Request Body

| Name     | Type   | Description                          |
| -------- | ------ | ------------------------------------ |
| output   | string | compose of address, asset and amount |
| password | string | 1234                                 |

{% tabs %}
{% tab title="200 Return the transaction hash of the send transaction" %}

```javascript
4f49f18a0575e701661d95cd221feb4399dc25e6f8230d37c4e2860cbd248fb9
```

{% endtab %}
{% endtabs %}

## Sign

<mark style="color:green;">`POST`</mark> `http://127.0.0.1:31567/wallet/sign`

#### Path Parameters

| Name     | Type   | Description           |
| -------- | ------ | --------------------- |
| password | string | wallet password       |
| message  | string | txhash                |
| path     | string | bit44 derivative path |

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

```
fcea0b7537c68117144dd95a801bbb9a2e2628463abd0eaf7e0eed2f5cc48e0219cb883ae22b9117d2a661f61a6a6b5612087fe19afa4576eff7c5fc62e2cdfb
```

{% endtab %}
{% endtabs %}

## Check Password

<mark style="color:green;">`POST`</mark> `http://127.0.0.1:31567/wallet/checkpassword`

#### Path Parameters

| Name     | Type   | Description     |
| -------- | ------ | --------------- |
| password | string | wallet password |

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

```
true
```

{% endtab %}
{% endtabs %}

## Retrive Mnemonic Phrase

<mark style="color:green;">`POST`</mark> `http://127.0.0.1:31567/wallet/mnemonicphrase`

#### Path Parameters

| Name     | Type   | Description     |
| -------- | ------ | --------------- |
| password | string | wallet password |

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

```
child brain left age apart couch napkin balcony lobster retreat situate retreat capital judge arch between cart puzzle truly note abuse violin spell fashion
```

{% endtab %}
{% endtabs %}

## Create Hex Transaction

<mark style="color:green;">`POST`</mark> `http://127.0.0.1:31567/wallet/createrawtransaction`

Create a hex transaction

#### Request Body

| Name     | Type   | Description                          |
| -------- | ------ | ------------------------------------ |
| password | string | wallet password                      |
| output   | array  | composed of address asset and amount |

{% tabs %}
{% tab title="200 Return the raw transaction" %}

```
0000000001014f49f18a0575e701661d95cd221feb4399dc25e6f8230d37c4e2860cbd248fb901020220afea2e549bc52e05673396161e175ba8b5d9afca75c658ec3c4739fc4feeca020000370220ecc94205df8142d81f469eb7c62db9b65f58a3e186250908ec855a32c5d1b466007e0001740ca8163200010162010360c63d3a8228f6ba18f10b487bc1e2526479db65b866cd408c9c6f2fe1e423cb2c0e82ef5cf046ad5c814e5404ad7fe2b7edfd76d0cb359a484ddda8e7ca9fd1356150ef28a1d2fc59115510fd38c5125f17f12b80661b168bf342e181df4810
```

{% endtab %}
{% endtabs %}

## Create raw transaction

<mark style="color:green;">`POST`</mark> `http://127.0.0.1:31567/wallet/rawtransaction/create`

Create an unsigned raw transaction

#### Path Parameters

| Name                                      | Type   | Description                          |
| ----------------------------------------- | ------ | ------------------------------------ |
| outputs<mark style="color:red;">\*</mark> | string | composed of address asset and amount |

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

```json
{
    "txHash": "87f899d158c39c15c73d97126982c735a24cca743a180c5555b104634c0d384c",
    "tx": "000000000101e003c9e673c3e386f40cd06c1d4e9f1ddebaa701393729a94a4ebb62e5e43e3301020220afea2e549bc52e05673396161e175ba8b5d9afca75c658ec3c4739fc4feeca02000037022072a6aa805930d89ba685c7919812209de5bdd9d3c4fb86903930286283db9ced007e000001bef88776000101340103cca577d0e3e738dcd5f90dd7bd76283365498e28455d6aa1e933c0ed5926768c116d2f3434272f323538272f30272f312f30"
}
```

{% endtab %}
{% endtabs %}

## Sign Raw Transaction

<mark style="color:green;">`POST`</mark> `http://127.0.0.1:31567/wallet/rawtransaction/sign`

Receive a raw transaction and sign it

#### Request Body

| Name                                       | Type   | Description                  |
| ------------------------------------------ | ------ | ---------------------------- |
| password<mark style="color:red;">\*</mark> | string | wallet password              |
| tx<mark style="color:red;">\*</mark>       | string | tx transaction in hex format |

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

```json
{
    "txHash": "87f899d158c39c15c73d97126982c735a24cca743a180c5555b104634c0d384c",
    "tx": "000000000101e003c9e673c3e386f40cd06c1d4e9f1ddebaa701393729a94a4ebb62e5e43e3301020220afea2e549bc52e05673396161e175ba8b5d9afca75c658ec3c4739fc4feeca02000037022072a6aa805930d89ba685c7919812209de5bdd9d3c4fb86903930286283db9ced007e000001bef887760001006401620103cca577d0e3e738dcd5f90dd7bd76283365498e28455d6aa1e933c0ed5926768c5f54068fc75add5135f9a52b965831650912b0ea40ca82d5697ebe4ae01bde1f18851a491fb477014ed29aa5a667da8ed669006806daa416d9492b23348c8de5"
}
```

{% endtab %}
{% endtabs %}

## Get Wallet Keys

<mark style="color:green;">`POST`</mark> `http://127.0.0.1:31567/wallet/keys`

Get imported public keys

#### Path Parameters

| Name     | Type   | Description     |
| -------- | ------ | --------------- |
| password | string | wallet password |

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

```
[
    {
        "publicKey": string,
        "path": "m/44'/258'/0'/1/0"
    }
]
```

{% endtab %}
{% endtabs %}

## Publish Raw Transaction

<mark style="color:green;">`POST`</mark> `http://127.0.0.1:31567/wallet/rawtransaction/publish`

Parse a transaction from raw, verify that is fully signed and then publish the transaction

#### Request Body

| Name                                 | Type   | Description             |
| ------------------------------------ | ------ | ----------------------- |
| tx<mark style="color:red;">\*</mark> | string | signed tx in hex format |

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

```
"87f899d158c39c15c73d97126982c735a24cca743a180c5555b104634c0d384c"
```

{% endtab %}
{% endtabs %}

## Import watchonly address

<mark style="color:green;">`POST`</mark> `http://127.0.0.1:31567/wallet/importwatchonlyaddress`

#### Request Body

| Name    | Type   | Description                 |
| ------- | ------ | --------------------------- |
| address | string | Address to add as watchonly |

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

```
added
```

{% endtab %}

{% tab title="400 " %}

```
Address already exist
```

{% endtab %}
{% endtabs %}

## Get new address

<mark style="color:green;">`POST`</mark> `http://127.0.0.1:31567/wallet/getnewaddress`

Get a new address

{% tabs %}
{% tab title="200 return a new address" %}

```
{
    "address": "tzn1qjcvncgt9lgs55983sz3a9ns8jhq3ukua747a7f7c87japw964usslwtgs6",
    "index": 0
}
```

{% endtab %}
{% endtabs %}

## Restore new address

<mark style="color:green;">`POST`</mark> `http://127.0.0.1:31567/wallet/restorenewaddresses`

#### Request Body

| Name                                  | Type   | Description |
| ------------------------------------- | ------ | ----------- |
| max<mark style="color:red;">\*</mark> | number |             |

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

```
```

{% endtab %}
{% endtabs %}

## Import Zen Public Key

<mark style="color:green;">`POST`</mark> `http://127.0.0.1:31567/wallet/importzenpublickey`

Import Zen Public Key

#### Request Body

| Name      | Type   | Description |
| --------- | ------ | ----------- |
| publicKey | string | public key  |

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

```
zenKey imported 
```

{% endtab %}
{% endtabs %}

## Execute Contract

<mark style="color:green;">`POST`</mark> `http://127.0.0.1:31567/wallet/contract/execute`

Run a smart contract with parameters

#### Request Body

| Name                                            | Type    | Description                                                                                                                                                                                                         |
| ----------------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| sign<mark style="color:red;">\*</mark>          | string  | path                                                                                                                                                                                                                |
| password<mark style="color:red;">\*</mark>      | string  | wallet password                                                                                                                                                                                                     |
| returnAddress<mark style="color:red;">\*</mark> | boolean | <p>Execute the contract with some default arguments, such as:<br> - returnAddress - allows the contract to automatically send funds back to in case it needs to. <br>{<br>    "returnAddress" : true/false<br>}</p> |
| message                                         | string  | send the contract some data                                                                                                                                                                                         |
| contractId<mark style="color:red;">\*</mark>    | string  | The contract address                                                                                                                                                                                                |
| command<mark style="color:red;">\*</mark>       | string  | <p>Trigger one of the functions in the contract such as:<br>"buy" / "redeem"</p>                                                                                                                                    |
| spends<mark style="color:red;">\*</mark>        | array   | an array of outputs                                                                                                                                                                                                 |

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

```javascript
daed7567b6a1bbcc20b996625fd81384727daf100b794b75726f5d3dd0ce9b5c
```

{% endtab %}
{% endtabs %}

## Activate Contract

<mark style="color:green;">`POST`</mark> `http://127.0.0.1:31567/wallet/contract/activate`

This how you activate a contract

#### Request Body

| Name           | Type   | Description                                                                                                                                                                                         |
| -------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| rlimit         | string | zebra's rlimit for recording hints                                                                                                                                                                  |
| password       | string | wallet password                                                                                                                                                                                     |
| numberOfBlocks | number | The number of blocks you want to activate your contract for                                                                                                                                         |
| code           | string | <p>Send valid fstar code, for example:<br><code>let main \_ \_ \_ \_ \_ \_ \_ \_ = Zen.ResultT.failw "This contract does nothing"\nlet cf \_ \_ \_ \_ \_ \_ \_ = Zen.Cost.ret (1 <: nat)</code></p> |

{% tabs %}
{% tab title="200 Cake successfully retrieved." %}

```javascript
{
    "address": "ctzn1qqqqqqqym4kfe8y5qg5tazkgjwn4qpesj05x6mqsvd5auwmzkhhs444fnkvwxhahr",
    "contractId": "000000009bad939392804517d1591274ea00e6127d0dad820c6d3bc76c56bde15ad533b3"
}
```

{% endtab %}

{% tab title="400 Could not find a matching in the query." %}

```javascript
```

{% endtab %}
{% endtabs %}

## Extend Contract

<mark style="color:green;">`POST`</mark> `http://127.0.0.1:31567/wallet/contract/extend`

This is to extend a contract

#### Request Body

| Name                                             | Type   | Description                                            |
| ------------------------------------------------ | ------ | ------------------------------------------------------ |
| password<mark style="color:red;">\*</mark>       | string | wallet password                                        |
| numberOfBlocks<mark style="color:red;">\*</mark> | string | Number of block until when the contract will be active |
| address<mark style="color:red;">\*</mark>        | string | address of the contract                                |

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

```
{
    "address": "ctzn1qqqqqqq8gjuu8rz5q9f7jz72p3qh0arjctcstyzgp8ydux7hjt7kz7gkg4v5lec88",
    "contractId": "00000000e89738718a802a7d217941882efe8e585e20b20901391bc37af25fac2f22c8ab",
    "txHash": "725bc205c88944e2b0cbdd5150027511cf91c9d6c0f103a31e61a9c8c6589c5d",
    "numberOfBlocks": "10"
}
```

{% endtab %}
{% endtabs %}

## Execute CGP Contract

<mark style="color:green;">`POST`</mark> `http://127.0.0.1:31567/wallet/contract/cgp`

Execute the CGP contract at the payout block

#### Request Body

| Name     | Type   | Description     |
| -------- | ------ | --------------- |
| password | string | wallet password |

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

```
6bde92400f3ffb52980e22bb821f385b0bf5d710c8c65ff056287521b3b005be
```

{% endtab %}
{% endtabs %}
