Skip to content

RPC API mining pool interaction

Paul edited this page May 31, 2023 · 6 revisions

RPC API mining pool pallet

The API should be utilized for the interaction with the Node by means of using any stand alone mining client app (ex. pass3d-pool). It allows to connect numbers of different mining devices to the Node, as long as they all stick the mining pool decentralized pallet rules. The API provides the mining app with the mining metadata by poscan_getMiningParams and ensures 3D objects to push into the Node by poscan_pushMiningObjectToPool for a new block proposal.

Request

{
"jsonrpc":"2.0",
"id":"request id",
"method":"poscan_getMiningParams", 
"params": [pool's P3D address]
}'

Getting mining metadata example

Request:

{"jsonrpc":"2.0","id":12,"method":"poscan_getMiningParams","params":["d1...Jzd"]}

Response:

{"jsonrpc":"2.0","result":["0x3389a38e89de659944f46b58c454f92c9cbc4a6e310e629d40451a05cdffdc31","0x048e478a76016c759b9321c36f72e896fe0492c37e157c4df75bf629d9f74bd7","0xeeed","0x14"],"id":12}

Parameters:

  • pub_key (Node's public key for client authorization and objects encryption)
  • pre_hash (before the block seal),
  • parent_hash (parent block hash),
  • actual network difficulty,
  • additional off-chain difficulty to proof the miner's works on the node side

Error example:

{"jsonrpc":"2.0","error":{"code":-32001,"message":"Custom error: No data"},"id":12}

Pushing the mining 3D object into the Node example

Request:

{"jsonrpc":"2.0","id":12,"method":"poscan_pushMiningObjectToPool","params":["d1...Jzd"]}

Parameters:

  • pool_id - pool's P3D address
  • member_id - miner's P3D address,
  • pre_hash - from the metadata,
  • parent_hash - from the metadata,
  • algo - recognition algorithm, {Grid2d,Grid2dV2}
  • dfclty - difficulty used for the mined hash (either min or target)
  • hash - the object hash proposal,
  • proof - miner's signature for the object hash proposal,
  • obj_id - object index (optional)
  • obj - 3D model in .obj format (the string like this this one, the object must be encrypted with ed25519 scheme, ecies-ed25519 lib should be used)

Use pass3d-pool client as a reference.