11.6 Synchronous Queries


11.6.1 Intro

Lo stato della blockchain può essere interrogato tramite il servizio GET REST API.

Il payload della risposta viene compresso utilizzando il formato "MessagePack" e inviato come byte semplici con l'intestazione Content-Type: application/octet-stream.

Attualmente il servizio consente di recuperare le seguenti informazioni:

  • ricevuta e contenuto della transazione.
  • informazioni sul blocco (intestazione).
  • informazioni sull'account/portafoglio.

11.6.2 Getting transaction content

Request URL: /api/v1/transaction/<ticket>

11.6.2.1 Input:

  • ticket: ticket di transazione come fornito dalla risposta del servizio di invio.

11.6.2.2 Output:

[
  [
    account,
    nonce,
    network,
    target,
    method,
    [
      signatureType,
      pubKeyValue
    ],
    args
  ],
  signature
]

In altre parole è la stessa struttura descritta [here] (Transaction-Format.md) ma senza chiavi.

NULL se ticket non trovato.

11.6.3 Getting transactions receipt

Request URL: /api/v1/receipt/<ticket>

11.6.3.1 Input:

  • ticket: ticket di transazione come fornito dalla risposta di invio.

11.6.3.2 Output:

[
  height
  index
  success
  returns
]
  • height: Numero. Numero di blocco in cui è stata inserita la transazione.
  • index: numero. Compensazione della transazione all'interno del blocco.
  • success: booleano. Vero se lo smart contract è stato eseguito correttamente.
  • returns: binario. Dati di output specifici del contratto intelligente.

NULL se ticket non trovato.

11.6.4 Getting Block info

Request URL: /api/v1/block/<height>

11.6.4.1 Input:

  • id: account identifier come descritto here.

11.6.4.2 Output:

[
  height,
  txs_count,
  prev_hash,
  txs_hash,
  rec_hash,
  state_hash,
]
  • height: Numero. Block offset all'interno della blockchain. Il blocco Genesis ha altezza 0.
  • txs_count: numero. Numero di transazioni all'interno di questo blocco.
  • prev_hash: Bytes. Hash del blocco precedente.
  • txs_hash: Bytes. Merkle tree root delle transazioni contenute all'interno di questo blocco.
  • rec_hash: Bytes. Merkle tree root delle ricevute contenute all'interno di questo blocco.
  • state_hash: Bytes. Merkle tree root dell'albero di tutti i conti (aka stato mondiale).

NULL se non trovato.

11.6.5 Getting account info

Request URL: /api/v1/account/<id>



11.6.5.1 Input:

  • id: account identifier come descritto here.

11.6.5.2 Output:

[
  id,
  assets,
  contract_ref,
  data_hash
]
  • id: String. Identificatore dell'account.
  • assets: mappa del nome dell'asset e dei suoi valori specifici dello smart contract (e.g. <"BTC", bytes>).
  • contract_ref: Bytes. Identificatore di contratto intelligente associato all'account. È definito come l'hash dei sorgenti WASM.
  • data_hash: Bytes. Merkle tree root dei dati associati all'account.ss

11.6.6 Session Example

11.6.7 Submit Transaction

  • type: POST
  • path: /api/vi/submit

Corpo di Richiesta:

{
  "data": {
    "account": "QmYHnEQLdf5...2SPgdXrJWFh5W696HPfq7i",
    "nonce": "a03a5500433cf88c",
    "network": "skynet",
    "target": "87b6239079719fc7e4349ec54baac9e04c20c48cf0c6a9d2b29b0ccf7c31c727",
    "method": "transfer",
    "caller": {
      "type": "ecdsa_p384r1",
      "value": "7cUWbhbYtrVqMpEyLXYh3RDAYgpNGzPFoA55ymm7NndERKxebZKMgXo35k3T4...w5k6aaYG96J4e2tWumVY4p1yv6hgSspSHVzvMKadYCHZByscm1oknaZjC86FF6"
    },
    "args": {
      "to": "QmTuhaS8rBRjBSxPYH...3fVtHJTuTbwwUSdnB8a",
      "amount": 19,
      "asset": "WPC"
    }
  },
  "signature": "MvbDchmXV1aHytKWr91aPCwsWAatmFG6fCusLmyJY6FcVf5ZZB4TjUhboXt...rAegZDH9rfBoHVTqihGscLnKbcLmGuoKWVu92uuX24MdK4ijKdiEx58E9QZpQyqS"
}

Corpo di risposta:

"12205b47bca14ab8cd339481a0717ac0b3f4b6601e8eb73804571b9335276306c791"

11.6.8 Get Transaction

  • type: GET
  • path: /api/v1/transaction/12205b47bca14ab8cd339481a0717ac0b3f4b6601e8eb73804571b9335276306c791

Corpo di risposta:

 
[
  [
    "QmYHn...",
    "a03a5500433cf88c",
    "skynet",
    "87b62390...",
    "transfer",
    [
      "ecdsa_p384r1",
      "7cUWbhbYtrV..."
    ],
    "82fcff2ba7..."
  ],
  "MvbDchmXV1..."
]

11.6.9 Get Receipt

  • type: GET
  • path: /api/v1/receipt/9QEDuUq12byR74Cf8W7DuUScz6S2fNpc69Kzrmf1ooQV

Corpo di risposta:

[
  344,
  0,
  true,
  null
]

11.6.10 Get Block

  • type: GET
  • path: /api/v1/block/344

Corpo di risposta:

[
  344,
  100,
  "e08ff0f6b4e0738c7b6fd1d033ba021cf1f36f882ff7167aae1e6a3bba10a8b5",
  "1c53e075e5962038dfeb5d2bae0581d4c1445345584168835f2935fdd4c7d880",
  "b2fc1d6be8bf1e55306ec56ab48bece541feec31187fe4438275c1cadaa4be1e",
  "34e3ecda323d9d8fd1b59c6e2026d694d5dd9eb821a57b9416dd3c1159778f16"
]

1!.6.11 Get Account

  • type: GET
  • path: /api/v1/account/QmYHnEQLdf5h7KYbjFPuHSRk2SPgdXrJWFh5W696HPfq7i {

Corpo di risposta:

[
  "QmYHnEQLdf5h7KYbjFPuHSRk2SPgdXrJWFh5W696HPfq7i",
  {
    "WPC": "94342fff0c"
  },
  "87b6239079719fc7e4349ec54baac9e04c20c48cf0c6a9d2b29b0ccf7c31c727",
  null,
]