Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

Mining API

Lars Kuhtz edited this page Nov 23, 2022 · 3 revisions
A ~chainweb-miner~ communicates with a ~chainweb-node~ via the following endpoints. ** Work Requests #+begin_quote Intent: I want a new BlockHeader to mine on. #+end_quote #+begin_example GET /chainweb/0.0/mainnet01/mining/work #+end_example Request Body (JSON): #+begin_src js { "account": "miner", "predicate": "keys-all", "public-keys": [ "f880a433d6e2a13a32b6169030f56245efdd8c1b8a5027e9ce98a88e886bef27" ] } #+end_src Response (Octet Stream): #+begin_example Work Bytes - 322 bytes ChainBytes(4) + TargetBytes(32) + HeaderBytes(286) The minimum information required to perform Proof-of-Work. No knowledge of Chainweb internals is necessary. #+end_example | Piece | Description | |-------------+---------------------------------------------| | ChainBytes | The chain selection made by the Node. | | TargetBytes | Encoded form of the current Hash Target. | | HeaderBytes | Encoded form of the Block Header. | [[https://github.com/kadena-io/chainweb-node/wiki/Block-Header-Binary-Encoding#work-header-binary-format][This wiki page]] provides further details about the encoding of work bytes. ** Solution Submission #+begin_quote Intent: I solved a block - here it is. #+end_quote #+begin_example POST /chainweb/0.0/mainnet01/mining/solved #+end_example Request Body (Octet Stream): #+begin_example Header Bytes - 286 bytes The original work received, updated internally with the Nonce that satisfies the Proof-of-Work. #+end_example ** Update Subscription #+begin_quote Intent: I am currently mining. Is the work I'm doing still worth it? #+end_quote #+begin_example GET /chainweb/0.0/mainnet01/mining/updates #+end_example Request Body (Octet Stream): #+begin_example Chain Bytes - 4 bytes The first 4 bytes received from a call to /mining/work. This tells the Node to only inform the Miner of a new Cut when the specific chain in question has updated. #+end_example Response (Server-Sent Event): #+begin_example A stream of Server-Sent Events with a single line: event:New Cut #+end_example

Clone this wiki locally