-
Notifications
You must be signed in to change notification settings - Fork 95
Mining API
Lars Kuhtz edited this page Nov 23, 2022
·
3 revisions
A chainweb-miner
communicates with a chainweb-node
via the following
endpoints.
Intent: I want a new BlockHeader to mine on.
GET /chainweb/0.0/mainnet01/mining/work
Request Body (JSON):
{
"account": "miner",
"predicate": "keys-all",
"public-keys": [
"f880a433d6e2a13a32b6169030f56245efdd8c1b8a5027e9ce98a88e886bef27"
]
}
Response (Octet Stream):
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.
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. |
This wiki page provides further details about the encoding of work bytes.
Intent: I solved a block - here it is.
POST /chainweb/0.0/mainnet01/mining/solved
Request Body (Octet Stream):
Header Bytes - 286 bytes The original work received, updated internally with the Nonce that satisfies the Proof-of-Work.
Intent: I am currently mining. Is the work I’m doing still worth it?
GET /chainweb/0.0/mainnet01/mining/updates
Request Body (Octet Stream):
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.
Response (Server-Sent Event):
A stream of Server-Sent Events with a single line: event:New Cut