Browse Source

Wallet RPC API

master
Slixe 1 year ago
commit
55d4924861
3 changed files with 1681 additions and 0 deletions
  1. +712
    -0
      DERO API - Français.md
  2. +257
    -0
      DERO API.postman_collection.json
  3. +712
    -0
      README.md

+ 712
- 0
DERO API - Français.md View File

@@ -0,0 +1,712 @@
# DERO-HE RPC API

Dero Project - dero.io
February 3, 2022

Written by [Slixe](https://github.com/Slixe).

## CONTENTS

### Daemon RPC API

TODO

### Wallet RPC API

Tout d'abord, notez que le serveur RPC n'est pas activé par défaut sur le wallet, pour se faire, lancez le wallet avec le paramètre `--rpc-server`.

Le serveur RPC écoutera sur le port `40403` sur testnet.


#### Echo
Endpoint de test permettant de vérifier que le serveur RPC est bien activé du côté du wallet.

##### Paramètres disponibles
| Name | Type | Mandatory | Comment |
|:----:|:--------:|:---------:|:---------------:|
| | []string | true | Array of string |

##### Body
```json
{
"jsonrpc": "2.0",
"id": "1",
"method": "Echo",
"params": ["Hello", "World", "!"]
}
```

##### cURL request
```json
curl -X POST \
http://127.0.0.1:40403/json_rpc \
-H 'content-type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "Echo",
"params": ["Hello", "World", "!"]
}'
```

##### Result
```json
{
"jsonrpc": "2.0",
"id": "1",
"result": "WALLET Hello World !"
}
```

#### Get Address
Renvoi l'adresse DERO du portefeuille permettant de recevoir des DERO ou autres tokens.

##### Paramètres disponibles
Aucun paramètre

##### Body
```json
{
"jsonrpc": "2.0",
"id": "1",
"method": "GetAddress"
}
```

##### cURL request
```json
curl -X POST \
http://127.0.0.1:40403/json_rpc \
-H 'content-type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "GetAddress"
}'
```

##### Result
```json
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"address": "deto1qyyhg0xznkaxt5udct6lnlylsexvwprun6jphv89xg008vq29jk4vqqayuknf"
}
}
```

#### Get Balance
Récupère le solde actuelle du portefeuille.

##### Paramètres disponibles
Aucun paramètre

##### Body
```json
{
"jsonrpc": "2.0",
"id": "1",
"method": "GetBalance"
}
```

##### cURL request
```json
curl -X POST \
http://127.0.0.1:40403/json_rpc \
-H 'content-type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "GetBalance"
}'
```

##### Result
```json
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"balance": 800000,
"unlocked_balance": 800000
}
}
```
**NOTE**: Le montant est au format atomique. Pour rappel, 10^5 (=100000) équivaut à un 1 DERO.

**Attention**: si cette adresse n'est pas enregistré sur la blockchain, vous aurez cette erreur:
```json
{
"jsonrpc": "2.0",
"id": "1",
"error": {
"code": -32098,
"message": "Account Unregistered"
}
}
```

#### Get Height
Retourne à quel hauteur de bloc le portefeuille est synchronisé.

##### Paramètres disponibles
Aucun paramètre

##### Body
```json
{
"jsonrpc": "2.0",
"id": "1",
"method": "GetHeight"
}
```

##### cURL request
```json
curl -X POST \
http://127.0.0.1:40403/json_rpc \
-H 'content-type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "GetHeight"
}'
```

##### Result
```json
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"height": 420
}
}
```

#### Get Transfer by TXID
Retourne les détails de la transaction basé sur son hash.

##### Paramètres disponibles
| Name | Type | Mandatory |
|:----:|:----:|:---------:|
| hash | Hash | true |

##### Body
```json
{
"jsonrpc": "2.0",
"id": "1",
"method": "GetTransferbyTXID",
"params": {
"txid": "2a74bcc6262f48630967129793f3b87dc30236f2cb5df6ebb09d620ec0cb503a"
}
}
```

##### cURL request
```json
curl -X POST \
http://127.0.0.1:40403/json_rpc \
-H 'content-type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "GetTransferbyTXID",
"params": {
"txid": "2a74bcc6262f48630967129793f3b87dc30236f2cb5df6ebb09d620ec0cb503a"
}
}'
```

##### Result
```json
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"entry": {
"height": 31297,
"topoheight": 31297,
"blockhash": "44e010e6ae56e66e75b158871570233a8a8b918491efc2d02ce793a7ce258612",
"minerreward": 0,
"tpos": 17,
"pos": 0,
"coinbase": false,
"incoming": true,
"txid": "2a74bcc6262f48630967129793f3b87dc30236f2cb5df6ebb09d620ec0cb503a",
"destination": "",
"amount": 500000,
"fees": 451,
"proof": "deroproof1qy3zfvkwdz87xa7mvxc0qq7nsmcgkl3gsf00a2amhk7fs2yu09r4uqdzvfyyskpqckdxyd8vgtzd75mjujsyzj6swrfdy6gw7alx78ak23v6ql60ewqxy4j4rgqq0gfqsjjq9u",
"status": 0,
"time": "2022-02-03T17:51:16.006+01:00",
"ewdata": "2efc785f92e9ffdaf1935186e0ffe561e500632722c73f95e741136389a347b8002642ae3d734c6b119a28884920036e895fc8e6a33f9c4ec6d90da1a4d1b65ef901",
"data": "AqFoQ29tbWVudFNySGVsbG8gZnJvbSBTbGl4ZSAhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
"payloadtype": 0,
"payload": "oWhDb21tZW50U3JIZWxsbyBmcm9tIFNsaXhlICEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"payload_rpc": [
{
"name": "Comment",
"datatype": "S",
"value": "Hello from Slixe !"
}
],
"sender": "deto1qyj4kx6azntn9psmg7dsfkuv9qs9xde0s94nmmhm2a0damffpm2zzqqcudacc",
"dstport": 0,
"srcport": 0
}
}
}
```

#### Get Transfers
Retourne toutes les transactions présentes dans le portefeuille par rapport aux filtres appliqués.

##### Paramètres disponibles
| Name | Type | Mandatory | Comment |
|:----------:|:------:|:---------:|:--------------------------:|
| scid | Hash | false | Smart Contract ID |
| coinbase | bool | false | Accept coinbase TX ? |
| in | bool | false | Accept incoming TX ? |
| out | bool | false | Accept outgoing TX ? |
| min_height | uint64 | false | Minimum height |
| max_height | uint64 | false | Maximum height |
| sender | string | false | Sender address equal |
| receiver | string | false | Receiver address equal |
| dstport | uint64 | false | Destination Port (Service) |
| srcport | uint64 | false | Source Port (Service) |

##### Body
```json
{
"jsonrpc": "2.0",
"id": "1",
"method": "GetTransfers",
"params": {
"out": true,
"in": true
}
}
```

##### cURL request
```json
curl -X POST \
http://127.0.0.1:40403/json_rpc \
-H 'content-type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "GetTransfers",
"params": {
"out": true,
"in": true
}
}'
```

##### Result
```json
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"entries": [
{
"height": 31297,
"topoheight": 31297,
"blockhash": "44e010e6ae56e66e75b158871570233a8a8b918491efc2d02ce793a7ce258612",
"minerreward": 0,
"tpos": 17,
"pos": 0,
"coinbase": false,
"incoming": true,
"txid": "2a74bcc6262f48630967129793f3b87dc30236f2cb5df6ebb09d620ec0cb503a",
"destination": "",
"amount": 500000,
"fees": 451,
"proof": "deroproof1qy3zfvkwdz87xa7mvxc0qq7nsmcgkl3gsf00a2amhk7fs2yu09r4uqdzvfyyskpqckdxyd8vgtzd75mjujsyzj6swrfdy6gw7alx78ak23v6ql60ewqxy4j4rgqq0gfqsjjq9u",
"status": 0,
"time": "2022-02-03T17:51:16.006+01:00",
"ewdata": "2efc785f92e9ffdaf1935186e0ffe561e500632722c73f95e741136389a347b8002642ae3d734c6b119a28884920036e895fc8e6a33f9c4ec6d90da1a4d1b65ef901",
"data": "AqFoQ29tbWVudFNySGVsbG8gZnJvbSBTbGl4ZSAhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
"payloadtype": 0,
"payload": "oWhDb21tZW50U3JIZWxsbyBmcm9tIFNsaXhlICEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"payload_rpc": [
{
"name": "Comment",
"datatype": "S",
"value": "Hello from Slixe !"
}
],
"sender": "deto1qyj4kx6azntn9psmg7dsfkuv9qs9xde0s94nmmhm2a0damffpm2zzqqcudacc",
"dstport": 0,
"srcport": 0
}
]
}
}
```

#### Make Integrated Address
Retourne une nouvelle adresse avec des Payloads inclus.

##### Paramètres disponibles
| Name | Type | Mandatory | Comment |
|:-----------:|:--------:|:---------:|:----------------------------------------------------:|
| address | string | false | DERO Address (if empty, the one from wallet is used) |
| payload_rpc | Argument | false | Parameters to include in address |

##### Body
```json
{
"jsonrpc": "2.0",
"id": "1",
"method": "MakeIntegratedAddress",
"params": {
"payload_rpc": [
{
"name": "Comment",
"datatype": "S",
"value": "Hello from integrated address !"
}
]
}
}
```

##### cURL request
```json
curl -X POST \
http://127.0.0.1:40403/json_rpc \
-H 'content-type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "MakeIntegratedAddress",
"params": {
"payload_rpc": [
{
"name": "Comment",
"datatype": "S",
"value": "Hello from integrated address !"
}
]
}
}'
```

##### Result
```json
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"integrated_address": "detoi1qyyhg0xznkaxt5udct6lnlylsexvwprun6jphv89xg008vq29jk4vq9pdppk7mtdv4h8g5mcrayx2mrvdusxvun0d5sxjmn5v4nhyct5v4jzqctyv3ex2umnyqssvnqraw",
"payload_rpc": [
{
"name": "Comment",
"datatype": "S",
"value": "Hello from integrated address !"
}
]
}
}
```

#### Split Integrated Address
Retourne l'adresse DERO et les payloads inclus dans une Integrated Address.

##### Paramètres disponibles
| Name | Type | Mandatory | Comment |
|:------------------:|:------:|:---------:|:----------------------------:|
| integrated_address | string | true | Integrated Address to decode |

##### Body
```json
{
"jsonrpc": "2.0",
"id": "1",
"method": "SplitIntegratedAddress",
"params": {
"integrated_address": "detoi1qyyhg0xznkaxt5udct6lnlylsexvwprun6jphv89xg008vq29jk4vq9pdppk7mtdv4h8g5mcrayx2mrvdusxvun0d5sxjmn5v4nhyct5v4jzqctyv3ex2umnyqssvnqraw"
}
}
```

##### cURL request
```json
curl -X POST \
http://127.0.0.1:40403/json_rpc \
-H 'content-type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "SplitIntegratedAddress",
"params": {
"integrated_address": "detoi1qyyhg0xznkaxt5udct6lnlylsexvwprun6jphv89xg008vq29jk4vq9pdppk7mtdv4h8g5mcrayx2mrvdusxvun0d5sxjmn5v4nhyct5v4jzqctyv3ex2umnyqssvnqraw"
}
}'
```

##### Result
```json
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"address": "deto1qyyhg0xznkaxt5udct6lnlylsexvwprun6jphv89xg008vq29jk4vqqayuknf",
"payload_rpc": [
{
"name": "Comment",
"datatype": "S",
"value": "Hello from integrated address !"
}
]
}
}
```

#### Query Key
Retourne la clé mnémonique (seed) associé à ce portefeuille.

##### Paramètres disponibles
| Name | Type | Mandatory | Comment |
|:--------:|:------:|:---------:|:--------------------------:|
| key_type | string | true | Key Type ("mnemonic" only) |

##### Body
```json
{
"jsonrpc": "2.0",
"id": "1",
"method": "QueryKey",
"params": {
"key_type": "mnemonic"
}
}
```

##### cURL request
```json
curl -X POST \
http://127.0.0.1:40403/json_rpc \
-H 'content-type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "QueryKey",
"params": {
"key_type": "mnemonic"
}
}'
```

##### Result:
```json
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"key": "eavesdrop sailor tavern fizzle mammal were utmost stellar rafts vats dedicated dosage lynx cent after toyed coexist zippers lipstick aztec dedicated custom chrome onto launching"
}
}
```

#### Transfer
Crée une transaction et renvoi son hash.

##### Paramètres disponibles
| Name | Type | Mandatory | Comment |
|:-----------:|:---------:|:---------:|:------------------------:|
| scid | Hash | false | SCID of asset |
| destination | string | false | DERO Address of receiver |
| amount | uint64 | false | Amount of token to send |
| burn | uint64 | false | Amount of token to burn |
| payload_rpc | Arguments | false | Payload Arguments |

##### Body
```json
{
"jsonrpc": "2.0",
"id": "1",
"method": "transfer",
"params": {
"scid": "00000000000000000000000000000000",
"destination": "deto1qyj4kx6azntn9psmg7dsfkuv9qs9xde0s94nmmhm2a0damffpm2zzqqcudacc",
"amount": 100000
}
}
```

##### cURL request
```json
curl -X POST \
http://127.0.0.1:40403/json_rpc \
-H 'content-type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "transfer",
"params": {
"scid": "00000000000000000000000000000000",
"destination": "deto1qyj4kx6azntn9psmg7dsfkuv9qs9xde0s94nmmhm2a0damffpm2zzqqcudacc",
"amount": 100000
}
}'
```

##### Result
```json
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"txid": "5201c319d04fb72012ecb2fd8c903feff50bbd5db39c60dfee795b9b3a90433a"
}
}
```

#### Transfer 2
Crée une transaction vers plusieurs adresses distinctes et renvoi son hash.

##### Paramètres disponibles
| Name | Type | Mandatory | Comment |
|:---------:|:----------:|:---------:|:-----------------------:|
| transfers | []Transfer | false | see previous request |
| sc | string | false | SC Code to deploy |
| sc_rpc | Arguments | false | SC Call arguments |
| ringsize | uint64 | false | Level of anonymity |
| scid | string | false | SCID to call |
| fees | uint64 | false | Tx Fees |
| signer | string | false | used for gas estimation |

##### Body
```json
{
"jsonrpc": "2.0",
"id": "1",
"method": "transfer",
"params": {
"transfers": [{
"destination": "deto1qyj4kx6azntn9psmg7dsfkuv9qs9xde0s94nmmhm2a0damffpm2zzqqcudacc",
"amount": 100000
},
{
"destination": "deto1qydvjhl67a3hmcw6zq9yt449extwshzcjxkd7lgk4uhgpyxdr494yqg6zwnc2",
"amount": 100000
}],
"ringsize": 32
}
}
```

##### cURL request
```json
curl -X POST \
http://127.0.0.1:40403/json_rpc \
-H 'content-type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "transfer",
"params": {
"transfers": [{
"destination": "deto1qyj4kx6azntn9psmg7dsfkuv9qs9xde0s94nmmhm2a0damffpm2zzqqcudacc",
"amount": 100000
},
{
"destination": "deto1qydvjhl67a3hmcw6zq9yt449extwshzcjxkd7lgk4uhgpyxdr494yqg6zwnc2",
"amount": 100000
}],
"ringsize": 32
}
}'
```

##### Result
```json
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"txid": "3a2712ae039e3f55b4cee132ec7ab76b912d05b3c1fc2744ae2ddd2c18be893e"
}
}
```

#### SC Invoke
Crée une transaction pour appeler une function du Smart Contract et retourne son hash.

##### Paramètres disponibles
| Name | Type | Mandatory | Comment |
|:----------------:|:---------:|:---------:|:--------------------------:|
| scid | string | true | SC ID of asset/token |
| sc_rpc | Arguments | true | SC Arguments |
| sc_dero_deposit | uint64 | false | Amount of DERO to deposit |
| sc_token_deposit | uint64 | false | Amount of token to deposit |
| ringsize | uint64 | false | Level of anonymity |

##### Body
```json
{
"jsonrpc": "2.0",
"id": "1",
"method": "scinvoke",
"params": {
"scid": "0000000000000000000000000000000000000000000000000000000000000001",
"ringsize": 2,
"sc_rpc": [{
"name": "entrypoint",
"datatype": "S",
"value": "Register"
},
{
"name": "name",
"datatype": "S",
"value": "Slixe"
}]
}
}
```

##### cURL request
```json
curl -X POST \
http://127.0.0.1:40403/json_rpc \
-H 'content-type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "scinvoke",
"params": {
"scid": "0000000000000000000000000000000000000000000000000000000000000001",
"ringsize": 2,
"sc_rpc": [{
"name": "entrypoint",
"datatype": "S",
"value": "Register"
},
{
"name": "name",
"datatype": "S",
"value": "Slixe"
}]
}
}'
```

##### Result
```json
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"txid": "bf4b2cd942f4394a03d0d66bbf8c0639f5cbcbf340becc39d4c9e02f987cecca"
}
}
```


+ 257
- 0
DERO API.postman_collection.json View File

@@ -0,0 +1,257 @@
{
"variables": [],
"info": {
"name": "DERO API",
"_postman_id": "66e2d2c2-9f7f-09de-cedd-79d6b18c9d47",
"description": "",
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
},
"item": [
{
"name": "Wallet",
"description": "",
"item": [
{
"name": "Echo",
"request": {
"url": "http://127.0.0.1:40403/json_rpc",
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": ""
}
],
"body": {
"mode": "raw",
"raw": "{\n \"jsonrpc\": \"2.0\",\n \"id\": \"1\",\n \"method\": \"Echo\",\n \"params\": [\"Hello\", \"World\", \"!\"]\n}"
},
"description": ""
},
"response": []
},
{
"name": "Get Address",
"request": {
"url": "http://127.0.0.1:40403/json_rpc",
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": ""
}
],
"body": {
"mode": "raw",
"raw": "{\n \"jsonrpc\": \"2.0\",\n \"id\": \"1\",\n \"method\": \"GetAddress\"\n}"
},
"description": ""
},
"response": []
},
{
"name": "Get Balance",
"request": {
"url": "http://127.0.0.1:40403/json_rpc",
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": ""
}
],
"body": {
"mode": "raw",
"raw": "{\n \"jsonrpc\": \"2.0\",\n \"id\": \"1\",\n \"method\": \"GetBalance\"\n}"
},
"description": ""
},
"response": []
},
{
"name": "Get Block Height",
"request": {
"url": "http://127.0.0.1:40403/json_rpc",
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": ""
}
],
"body": {
"mode": "raw",
"raw": "{\n \"jsonrpc\": \"2.0\",\n \"id\": \"1\",\n \"method\": \"GetHeight\"\n}"
},
"description": ""
},
"response": []
},
{
"name": "Get Transfer By TXID",
"request": {
"url": "http://127.0.0.1:40403/json_rpc",
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": ""
}
],
"body": {
"mode": "raw",
"raw": "{\n \"jsonrpc\": \"2.0\",\n \"id\": \"1\",\n \"method\": \"GetTransferbyTXID\",\n \"params\": {\n \t\"txid\": \"2a74bcc6262f48630967129793f3b87dc30236f2cb5df6ebb09d620ec0cb503a\"\n }\n}"
},
"description": ""
},
"response": []
},
{
"name": "Get Transfers",
"request": {
"url": "http://127.0.0.1:40403/json_rpc",
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": ""
}
],
"body": {
"mode": "raw",
"raw": "{\n \"jsonrpc\": \"2.0\",\n \"id\": \"1\",\n \"method\": \"GetTransfers\",\n \"params\": {\n \t\"out\": true,\n \t\"in\": true\n }\n}"
},
"description": ""
},
"response": []
},
{
"name": "Make Integrated Address",
"request": {
"url": "http://127.0.0.1:40403/json_rpc",
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": ""
}
],
"body": {
"mode": "raw",
"raw": "{\n \"jsonrpc\": \"2.0\",\n \"id\": \"1\",\n \"method\": \"MakeIntegratedAddress\",\n \"params\": {\n \t\"payload_rpc\": [\n {\n \"name\": \"Comment\",\n \"datatype\": \"S\",\n \"value\": \"Hello from integrated address !\"\n }\n ]\n }\n}"
},
"description": ""
},
"response": []
},
{
"name": "Split Integrated Address",
"request": {
"url": "http://127.0.0.1:40403/json_rpc",
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": ""
}
],
"body": {
"mode": "raw",
"raw": "{\n \"jsonrpc\": \"2.0\",\n \"id\": \"1\",\n \"method\": \"SplitIntegratedAddress\",\n \"params\": {\n \t\"integrated_address\": \"detoi1qyyhg0xznkaxt5udct6lnlylsexvwprun6jphv89xg008vq29jk4vq9pdppk7mtdv4h8g5mcrayx2mrvdusxvun0d5sxjmn5v4nhyct5v4jzqctyv3ex2umnyqssvnqraw\"\n }\n}"
},
"description": ""
},
"response": []
},
{
"name": "Query Key",
"request": {
"url": "http://127.0.0.1:40403/json_rpc",
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": ""
}
],
"body": {
"mode": "raw",
"raw": "{\n \"jsonrpc\": \"2.0\",\n \"id\": \"1\",\n \"method\": \"QueryKey\",\n \"params\": {\n \t\"key_type\": \"mnemonic\"\n }\n}"
},
"description": ""
},
"response": []
},
{
"name": "Transfer",
"request": {
"url": "http://127.0.0.1:40403/json_rpc",
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": ""
}
],
"body": {
"mode": "raw",
"raw": "{\n \"jsonrpc\": \"2.0\",\n \"id\": \"1\",\n \"method\": \"transfer\",\n \"params\": {\n \t\"scid\": \"00000000000000000000000000000000\",\n \t\"destination\": \"deto1qyj4kx6azntn9psmg7dsfkuv9qs9xde0s94nmmhm2a0damffpm2zzqqcudacc\",\n \t\"amount\": 100000\n }\n}"
},
"description": ""
},
"response": []
},
{
"name": "Transfer Split",
"request": {
"url": "http://127.0.0.1:40403/json_rpc",
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": ""
}
],
"body": {
"mode": "raw",
"raw": "{\n \"jsonrpc\": \"2.0\",\n \"id\": \"1\",\n \"method\": \"transfer\",\n \"params\": {\n \t\"transfers\": [{\n\t\t\t\"destination\": \"deto1qyj4kx6azntn9psmg7dsfkuv9qs9xde0s94nmmhm2a0damffpm2zzqqcudacc\",\n\t\t\t\"amount\": 100000\n\t\t},\n\t\t{\n\t\t\t\"destination\": \"deto1qydvjhl67a3hmcw6zq9yt449extwshzcjxkd7lgk4uhgpyxdr494yqg6zwnc2\",\n\t\t\t\"amount\": 100000\n\t\t}],\n \t\"ringsize\": 32\n }\n}"
},
"description": ""
},
"response": []
},
{
"name": "SC Invoke",
"request": {
"url": "http://127.0.0.1:40403/json_rpc",
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": ""
}
],
"body": {
"mode": "raw",
"raw": "{\n \"jsonrpc\": \"2.0\",\n \"id\": \"1\",\n \"method\": \"scinvoke\",\n \"params\": {\n \t\"scid\": \"0000000000000000000000000000000000000000000000000000000000000001\",\n \t\"ringsize\": 2,\n \t\"sc_rpc\": [{\n \t\t\"name\": \"entrypoint\",\n \t\t\"datatype\": \"S\",\n \t\t\"value\": \"Register\"\n \t},\n \t{\n \t\t\"name\": \"name\",\n \t\t\"datatype\": \"S\",\n \t\t\"value\": \"Slixe\"\n \t}]\n }\n}"
},
"description": ""
},
"response": []
}
]
}
]
}

+ 712
- 0
README.md View File

@@ -0,0 +1,712 @@
# DERO-HE RPC API

Dero Project - dero.io
February 3, 2022

Written by [Slixe](https://github.com/Slixe).

## CONTENTS

### Daemon RPC API

TODO

### Wallet RPC API

First, note that the RPC server is not enabled by default on the wallet, to do this, start the wallet with the `--rpc-server` parameter.

The RPC server will listen on port `40403` on testnet.


#### Echo
Test endpoint to verify that the RPC server is enabled and working well on the wallet side.

##### Available parameters
| Name | Type | Mandatory | Comment |
|:----:|:--------:|:---------:|:---------------:|
| | []string | true | Array of string |

##### Body
```json
{
"jsonrpc": "2.0",
"id": "1",
"method": "Echo",
"params": ["Hello", "World", "!"]
}
```

##### cURL request
```json
curl -X POST \
http://127.0.0.1:40403/json_rpc \
-H 'content-type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "Echo",
"params": ["Hello", "World", "!"]
}'
```

##### Result
```json
{
"jsonrpc": "2.0",
"id": "1",
"result": "WALLET Hello World !"
}
```

#### Get Address
Returns the DERO address of the wallet to receive DEROs or other tokens.

##### Available parameters
No parameters

##### Body
```json
{
"jsonrpc": "2.0",
"id": "1",
"method": "GetAddress"
}
```

##### cURL request
```json
curl -X POST \
http://127.0.0.1:40403/json_rpc \
-H 'content-type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "GetAddress"
}'
```

##### Result
```json
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"address": "deto1qyyhg0xznkaxt5udct6lnlylsexvwprun6jphv89xg008vq29jk4vqqayuknf"
}
}
```

#### Get Balance
Retrieves the current balance of the wallet.

##### Available parameters
No parameters

##### Body
```json
{
"jsonrpc": "2.0",
"id": "1",
"method": "GetBalance"
}
```

##### cURL request
```json
curl -X POST \
http://127.0.0.1:40403/json_rpc \
-H 'content-type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "GetBalance"
}'
```

##### Result
```json
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"balance": 800000,
"unlocked_balance": 800000
}
}
```
**NOTE**: The amount is in atomic format. As a reminder, 10^5 (=100000) is equivalent to 1 DERO.

**Warning**: if this address is not registered on the blockchain, you will get this error:
```json
{
"jsonrpc": "2.0",
"id": "1",
"error": {
"code": -32098,
"message": "Account Unregistered"
}
}
```

#### Get Height
Returns at which block height the wallet is synchronized.

##### Available parameters
No parameters

##### Body
```json
{
"jsonrpc": "2.0",
"id": "1",
"method": "GetHeight"
}
```

##### cURL request
```json
curl -X POST \
http://127.0.0.1:40403/json_rpc \
-H 'content-type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "GetHeight"
}'
```

##### Result
```json
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"height": 420
}
}
```

#### Get Transfer by TXID
Returns the details of the transaction based on its hash.

##### Available parameters
| Name | Type | Mandatory |
|:----:|:----:|:---------:|
| hash | Hash | true |

##### Body
```json
{
"jsonrpc": "2.0",
"id": "1",
"method": "GetTransferbyTXID",
"params": {
"txid": "2a74bcc6262f48630967129793f3b87dc30236f2cb5df6ebb09d620ec0cb503a"
}
}
```

##### cURL request
```json
curl -X POST \
http://127.0.0.1:40403/json_rpc \
-H 'content-type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "GetTransferbyTXID",
"params": {
"txid": "2a74bcc6262f48630967129793f3b87dc30236f2cb5df6ebb09d620ec0cb503a"
}
}'
```

##### Result
```json
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"entry": {
"height": 31297,
"topoheight": 31297,
"blockhash": "44e010e6ae56e66e75b158871570233a8a8b918491efc2d02ce793a7ce258612",
"minerreward": 0,
"tpos": 17,
"pos": 0,
"coinbase": false,
"incoming": true,
"txid": "2a74bcc6262f48630967129793f3b87dc30236f2cb5df6ebb09d620ec0cb503a",
"destination": "",
"amount": 500000,
"fees": 451,
"proof": "deroproof1qy3zfvkwdz87xa7mvxc0qq7nsmcgkl3gsf00a2amhk7fs2yu09r4uqdzvfyyskpqckdxyd8vgtzd75mjujsyzj6swrfdy6gw7alx78ak23v6ql60ewqxy4j4rgqq0gfqsjjq9u",
"status": 0,
"time": "2022-02-03T17:51:16.006+01:00",
"ewdata": "2efc785f92e9ffdaf1935186e0ffe561e500632722c73f95e741136389a347b8002642ae3d734c6b119a28884920036e895fc8e6a33f9c4ec6d90da1a4d1b65ef901",
"data": "AqFoQ29tbWVudFNySGVsbG8gZnJvbSBTbGl4ZSAhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
"payloadtype": 0,
"payload": "oWhDb21tZW50U3JIZWxsbyBmcm9tIFNsaXhlICEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"payload_rpc": [
{
"name": "Comment",
"datatype": "S",
"value": "Hello from Slixe !"
}
],
"sender": "deto1qyj4kx6azntn9psmg7dsfkuv9qs9xde0s94nmmhm2a0damffpm2zzqqcudacc",
"dstport": 0,
"srcport": 0
}
}
}
```

#### Get Transfers
Returns all transactions present in the portfolio against the applied filters.

##### Available parameters
| Name | Type | Mandatory | Comment |
|:----------:|:------:|:---------:|:--------------------------:|
| scid | Hash | false | Smart Contract ID |
| coinbase | bool | false | Accept coinbase TX ? |
| in | bool | false | Accept incoming TX ? |
| out | bool | false | Accept outgoing TX ? |
| min_height | uint64 | false | Minimum height |
| max_height | uint64 | false | Maximum height |
| sender | string | false | Sender address equal |
| receiver | string | false | Receiver address equal |
| dstport | uint64 | false | Destination Port (Service) |
| srcport | uint64 | false | Source Port (Service) |

##### Body
```json
{
"jsonrpc": "2.0",
"id": "1",
"method": "GetTransfers",
"params": {
"out": true,
"in": true
}
}
```

##### cURL request
```json
curl -X POST \
http://127.0.0.1:40403/json_rpc \
-H 'content-type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "GetTransfers",
"params": {
"out": true,
"in": true
}
}'
```

##### Result
```json
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"entries": [
{
"height": 31297,
"topoheight": 31297,
"blockhash": "44e010e6ae56e66e75b158871570233a8a8b918491efc2d02ce793a7ce258612",
"minerreward": 0,
"tpos": 17,
"pos": 0,
"coinbase": false,
"incoming": true,
"txid": "2a74bcc6262f48630967129793f3b87dc30236f2cb5df6ebb09d620ec0cb503a",
"destination": "",
"amount": 500000,
"fees": 451,
"proof": "deroproof1qy3zfvkwdz87xa7mvxc0qq7nsmcgkl3gsf00a2amhk7fs2yu09r4uqdzvfyyskpqckdxyd8vgtzd75mjujsyzj6swrfdy6gw7alx78ak23v6ql60ewqxy4j4rgqq0gfqsjjq9u",
"status": 0,
"time": "2022-02-03T17:51:16.006+01:00",
"ewdata": "2efc785f92e9ffdaf1935186e0ffe561e500632722c73f95e741136389a347b8002642ae3d734c6b119a28884920036e895fc8e6a33f9c4ec6d90da1a4d1b65ef901",
"data": "AqFoQ29tbWVudFNySGVsbG8gZnJvbSBTbGl4ZSAhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
"payloadtype": 0,
"payload": "oWhDb21tZW50U3JIZWxsbyBmcm9tIFNsaXhlICEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"payload_rpc": [
{
"name": "Comment",
"datatype": "S",
"value": "Hello from Slixe !"
}
],
"sender": "deto1qyj4kx6azntn9psmg7dsfkuv9qs9xde0s94nmmhm2a0damffpm2zzqqcudacc",
"dstport": 0,
"srcport": 0
}
]
}
}
```

#### Make Integrated Address
Returns a new integrated address with Payloads included.

##### Available parameters
| Name | Type | Mandatory | Comment |
|:-----------:|:--------:|:---------:|:----------------------------------------------------:|
| address | string | false | DERO Address (if empty, the one from wallet is used) |
| payload_rpc | Argument | false | Parameters to include in address |

##### Body
```json
{
"jsonrpc": "2.0",
"id": "1",
"method": "MakeIntegratedAddress",
"params": {
"payload_rpc": [
{
"name": "Comment",
"datatype": "S",
"value": "Hello from integrated address !"
}
]
}
}
```

##### cURL request
```json
curl -X POST \
http://127.0.0.1:40403/json_rpc \
-H 'content-type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "MakeIntegratedAddress",
"params": {
"payload_rpc": [
{
"name": "Comment",
"datatype": "S",
"value": "Hello from integrated address !"
}
]
}
}'
```

##### Result
```json
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"integrated_address": "detoi1qyyhg0xznkaxt5udct6lnlylsexvwprun6jphv89xg008vq29jk4vq9pdppk7mtdv4h8g5mcrayx2mrvdusxvun0d5sxjmn5v4nhyct5v4jzqctyv3ex2umnyqssvnqraw",
"payload_rpc": [
{
"name": "Comment",
"datatype": "S",
"value": "Hello from integrated address !"
}
]
}
}
```

#### Split Integrated Address
Returns the DERO address and the payloads included in an Integrated Address.

##### Available parameters
| Name | Type | Mandatory | Comment |
|:------------------:|:------:|:---------:|:----------------------------:|
| integrated_address | string | true | Integrated Address to decode |

##### Body
```json
{
"jsonrpc": "2.0",
"id": "1",
"method": "SplitIntegratedAddress",
"params": {
"integrated_address": "detoi1qyyhg0xznkaxt5udct6lnlylsexvwprun6jphv89xg008vq29jk4vq9pdppk7mtdv4h8g5mcrayx2mrvdusxvun0d5sxjmn5v4nhyct5v4jzqctyv3ex2umnyqssvnqraw"
}
}
```

##### cURL request
```json
curl -X POST \
http://127.0.0.1:40403/json_rpc \
-H 'content-type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "SplitIntegratedAddress",
"params": {
"integrated_address": "detoi1qyyhg0xznkaxt5udct6lnlylsexvwprun6jphv89xg008vq29jk4vq9pdppk7mtdv4h8g5mcrayx2mrvdusxvun0d5sxjmn5v4nhyct5v4jzqctyv3ex2umnyqssvnqraw"
}
}'
```

##### Result
```json
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"address": "deto1qyyhg0xznkaxt5udct6lnlylsexvwprun6jphv89xg008vq29jk4vqqayuknf",
"payload_rpc": [
{
"name": "Comment",
"datatype": "S",
"value": "Hello from integrated address !"
}
]
}
}
```

#### Query Key
Returns the mnemonic key (seed) associated with this portfolio.

##### Available parameters
| Name | Type | Mandatory | Comment |
|:--------:|:------:|:---------:|:--------------------------:|
| key_type | string | true | Key Type ("mnemonic" only) |

##### Body
```json
{
"jsonrpc": "2.0",
"id": "1",
"method": "QueryKey",
"params": {
"key_type": "mnemonic"
}
}
```

##### cURL request
```json
curl -X POST \
http://127.0.0.1:40403/json_rpc \
-H 'content-type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "QueryKey",
"params": {
"key_type": "mnemonic"
}
}'
```

##### Result:
```json
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"key": "eavesdrop sailor tavern fizzle mammal were utmost stellar rafts vats dedicated dosage lynx cent after toyed coexist zippers lipstick aztec dedicated custom chrome onto launching"
}
}
```

#### Transfer
Creates a transaction and returns its hash.

##### Available parameters
| Name | Type | Mandatory | Comment |
|:-----------:|:---------:|:---------:|:------------------------:|
| scid | Hash | false | SCID of asset |
| destination | string | false | DERO Address of receiver |
| amount | uint64 | false | Amount of token to send |
| burn | uint64 | false | Amount of token to burn |
| payload_rpc | Arguments | false | Payload Arguments |

##### Body
```json
{
"jsonrpc": "2.0",
"id": "1",
"method": "transfer",
"params": {
"scid": "00000000000000000000000000000000",
"destination": "deto1qyj4kx6azntn9psmg7dsfkuv9qs9xde0s94nmmhm2a0damffpm2zzqqcudacc",
"amount": 100000
}
}
```

##### cURL request
```json
curl -X POST \
http://127.0.0.1:40403/json_rpc \
-H 'content-type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "transfer",
"params": {
"scid": "00000000000000000000000000000000",
"destination": "deto1qyj4kx6azntn9psmg7dsfkuv9qs9xde0s94nmmhm2a0damffpm2zzqqcudacc",
"amount": 100000
}
}'
```

##### Result
```json
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"txid": "5201c319d04fb72012ecb2fd8c903feff50bbd5db39c60dfee795b9b3a90433a"
}
}
```

#### Transfer 2
Creates a transaction to several distinct addresses and returns its hash.

##### Available parameters
| Name | Type | Mandatory | Comment |
|:---------:|:----------:|:---------:|:-----------------------:|
| transfers | []Transfer | false | see previous request |
| sc | string | false | SC Code to deploy |
| sc_rpc | Arguments | false | SC Call arguments |
| ringsize | uint64 | false | Level of anonymity |
| scid | string | false | SCID to call |
| fees | uint64 | false | Tx Fees |
| signer | string | false | used for gas estimation |

##### Body
```json
{
"jsonrpc": "2.0",
"id": "1",
"method": "transfer",
"params": {
"transfers": [{
"destination": "deto1qyj4kx6azntn9psmg7dsfkuv9qs9xde0s94nmmhm2a0damffpm2zzqqcudacc",
"amount": 100000
},
{
"destination": "deto1qydvjhl67a3hmcw6zq9yt449extwshzcjxkd7lgk4uhgpyxdr494yqg6zwnc2",
"amount": 100000
}],
"ringsize": 32
}
}
```

##### cURL request
```json
curl -X POST \
http://127.0.0.1:40403/json_rpc \
-H 'content-type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "transfer",
"params": {
"transfers": [{
"destination": "deto1qyj4kx6azntn9psmg7dsfkuv9qs9xde0s94nmmhm2a0damffpm2zzqqcudacc",
"amount": 100000
},
{
"destination": "deto1qydvjhl67a3hmcw6zq9yt449extwshzcjxkd7lgk4uhgpyxdr494yqg6zwnc2",
"amount": 100000
}],
"ringsize": 32
}
}'
```

##### Result
```json
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"txid": "3a2712ae039e3f55b4cee132ec7ab76b912d05b3c1fc2744ae2ddd2c18be893e"
}
}
```

#### SC Invoke
Creates a transaction to call a Smart Contract function and returns its hash.

##### Available parameters
| Name | Type | Mandatory | Comment |
|:----------------:|:---------:|:---------:|:--------------------------:|
| scid | string | true | SC ID of asset/token |
| sc_rpc | Arguments | true | SC Arguments |
| sc_dero_deposit | uint64 | false | Amount of DERO to deposit |
| sc_token_deposit | uint64 | false | Amount of token to deposit |
| ringsize | uint64 | false | Level of anonymity |

##### Body
```json
{
"jsonrpc": "2.0",
"id": "1",
"method": "scinvoke",
"params": {
"scid": "0000000000000000000000000000000000000000000000000000000000000001",
"ringsize": 2,
"sc_rpc": [{
"name": "entrypoint",
"datatype": "S",
"value": "Register"
},
{
"name": "name",
"datatype": "S",
"value": "Slixe"
}]
}
}
```

##### cURL request
```json
curl -X POST \
http://127.0.0.1:40403/json_rpc \
-H 'content-type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "scinvoke",
"params": {
"scid": "0000000000000000000000000000000000000000000000000000000000000001",
"ringsize": 2,
"sc_rpc": [{
"name": "entrypoint",
"datatype": "S",
"value": "Register"
},
{
"name": "name",
"datatype": "S",
"value": "Slixe"
}]
}
}'
```

##### Result
```json
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"txid": "bf4b2cd942f4394a03d0d66bbf8c0639f5cbcbf340becc39d4c9e02f987cecca"
}
}
```


Loading…
Cancel
Save