CKB miner

get_block_by_number

echo '{
    "id": 2,
    "jsonrpc": "2.0",
    "method": "get_block_by_number",
    "params": [
        "2"
    ]
}' \
| tr -d '\n' \
| curl -H 'content-type: application/json' -d @- \
http://localhost:8114

//////////////////////
{
    "jsonrpc":"2.0",
    "result":{
        "header":{
            "difficulty":"0x1000",
            "epoch":"0",
            "hash":"0x13f1a32590626448f192b9d80e24b5b6fe10cfa8a7c418d795ce7f205ad88052",
            "number":"2",
            "parent_hash":"0x1ac66e1545399a685620b7ccd0e2c1864c6b1cc3372364b32f6ef39d1fe86bc2",
            "proposals_hash":"0x0000000000000000000000000000000000000000000000000000000000000000",
            "seal":{
                "nonce":"12821503273579817674",
                "proof":"0x380a0000b727000039290000c5290000f03a0000da3b000039460000df550000286f0000827000003b76000090770000"
            },
            "timestamp":"1559369405166",
            "transactions_root":"0xdb5c0dd9acd4c8913a260322ea017ef048a008ffed58bc82066b8c370867b511",
            "uncles_count":"0",
            "uncles_hash":"0x0000000000000000000000000000000000000000000000000000000000000000",
            "version":"0",
            "witnesses_root":"0x0000000000000000000000000000000000000000000000000000000000000000"
        },
        "proposals":[

        ],
        "transactions":[
            {
                "deps":[

                ],
                "hash":"0xdb5c0dd9acd4c8913a260322ea017ef048a008ffed58bc82066b8c370867b511",
                "inputs":[
                    {
                        "args":[
                            "0x0200000000000000"
                        ],
                        "previous_output":{
                            "block_hash":null,
                            "cell":null
                        },
                        "since":"0"
                    }
                ],
                "outputs":[
                    {
                        "capacity":"250000000000",
                        "data":"0x",
                        "lock":{
                            "args":[
                                "0xda648442dbb7347e467d1d09da13e5cd3a0ef0e1"
                            ],
                            "code_hash":"0x9e3b3557f11b2b3532ce352bfe8017e9fd11d154c4c7f9b7aaaa1e621b539a08"
                        },
                        "type":null
                    }
                ],
                "version":"0",
                "witnesses":[

                ]
            }
        ],
        "uncles":[

        ]
    },
    "id":2
}
echo '{
    "id": 2,
    "jsonrpc": "2.0",
    "method": "get_block_by_number",
    "params": [
        "3"
    ]
}' \
| tr -d '\n' \
| curl -H 'content-type: application/json' -d @- \
http://localhost:8114

//////////////////////

{
    "jsonrpc":"2.0",
    "result":{
        "header":{
            "difficulty":"0x1000",
            "epoch":"0",
            "hash":"0x396c65524f073800086321d11b92d1aeea9dacbf2d1587cafd838d2e25239862",
            "number":"3",
            "parent_hash":"0x13f1a32590626448f192b9d80e24b5b6fe10cfa8a7c418d795ce7f205ad88052",
            "proposals_hash":"0x0000000000000000000000000000000000000000000000000000000000000000",
            "seal":{
                "nonce":"5115149990558450539",
                "proof":"0xfb010000ee0d0000b71d00009a2a0000ca4800003d4c0000434e0000aa5100006e530000615a00005d6b0000647a0000"
            },
            "timestamp":"1559369460829",
            "transactions_root":"0xd7e215910b029832cea15102c8cced7e8019cfbfbfda8b122da0fc8572069903",
            "uncles_count":"1",
            "uncles_hash":"0x3388dc0b50fddbe202da8b8605f001de4743465ffeb95a8273f76454fd4411a5",
            "version":"0",
            "witnesses_root":"0x0000000000000000000000000000000000000000000000000000000000000000"
        },
        "proposals":[

        ],
        "transactions":[
            {
                "deps":[

                ],
                "hash":"0xd7e215910b029832cea15102c8cced7e8019cfbfbfda8b122da0fc8572069903",
                "inputs":[
                    {
                        "args":[
                            "0x0300000000000000"
                        ],
                        "previous_output":{
                            "block_hash":null,
                            "cell":null
                        },
                        "since":"0"
                    }
                ],
                "outputs":[
                    {
                        "capacity":"250000000000",
                        "data":"0x",
                        "lock":{
                            "args":[
                                "0xda648442dbb7347e467d1d09da13e5cd3a0ef0e1"
                            ],
                            "code_hash":"0x9e3b3557f11b2b3532ce352bfe8017e9fd11d154c4c7f9b7aaaa1e621b539a08"
                        },
                        "type":null
                    }
                ],
                "version":"0",
                "witnesses":[

                ]
            }
        ],
        "uncles":[
            {
                "header":{
                    "difficulty":"0x1000",
                    "epoch":"0",
                    "hash":"0xe9661f2f5a25b935b5c1d487526a636721e398e16fdf0d1ea0f9bf291ed983ad",
                    "number":"1",
                    "parent_hash":"0xeb897810b75a922309d748c0d16e7a980e0de1cc0ba0e0e3e3bda6f2e03cbc1b",
                    "proposals_hash":"0x0000000000000000000000000000000000000000000000000000000000000000",
                    "seal":{
                        "nonce":"15692437595251747273",
                        "proof":"0xa9010000650b00007f0c00007c2300006c2a0000534a0000e24a00008a500000415d0000dd5f00002666000048780000"
                    },
                    "timestamp":"1559369375209",
                    "transactions_root":"0x35def17c9ccb6f6cc45e994fe75be4265f3d0f17bc109762670ca9d26a0b8556",
                    "uncles_count":"0",
                    "uncles_hash":"0x0000000000000000000000000000000000000000000000000000000000000000",
                    "version":"0",
                    "witnesses_root":"0x0000000000000000000000000000000000000000000000000000000000000000"
                },
                "proposals":[

                ]
            }
        ]
    },
    "id":2
}

get_block_template

echo '{
    "id": 2,
    "jsonrpc": "2.0",
    "method": "get_block_template",
    "params": [
    ]
}' \
| tr -d '\n' \
| curl -H 'content-type: application/json' -d @- \
http://localhost:8114
{
    "jsonrpc":"2.0",
    "result":{
        "bytes_limit":"2000000",
        "cellbase":{
            "cycles":null,
            "data":{
                "deps":[

                ],
                "inputs":[
                    {
                        "args":[
                            "0xa468000000000000"
                        ],
                        "previous_output":{
                            "block_hash":null,
                            "cell":null
                        },
                        "since":"0"
                    }
                ],
                "outputs":[
                    {
                        "capacity":"138888888889",
                        "data":"0x",
                        "lock":{
                            "args":[
                                "0xb144a17a8938c763b38e5239f7267a0c3e628f08"
                            ],
                            "code_hash":"0x9e3b3557f11b2b3532ce352bfe8017e9fd11d154c4c7f9b7aaaa1e621b539a08"
                        },
                        "type":null
                    }
                ],
                "version":"0",
                "witnesses":[

                ]
            },
            "hash":"0x45a37088b7ddee00e908e054a466ea1586a23ca8c9852696334e9c7a4f604680"
        },
        "current_time":"1559670391087",
        "cycles_limit":"10000000000",
        "difficulty":"0x2728",
        "epoch":"8",
        "number":"26788",
        "parent_hash":"0x4f6e767192434284851149c1b07df8c3962fbb9bc0d05a34ea1d3d3e52c6f9c2",
        "proposals":[

        ],
        "transactions":[

        ],
        "uncles":[

        ],
        "uncles_count_limit":"2",
        "version":"0",
        "work_id":"0"
    },
    "id":2
}

submit_block

curl -H 'content-type:application/json' 'http://localhost:8114' \
-d '{"id": 2, "jsonrpc": "2.0", "method":"submit_block","params": [{"header":{}, "uncles":[], "transactions":[], "proposals":[]}]}' 

Reference:
https://github.com/nervosnetwork/ckb/blob/develop/rpc/README.md

https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0013-get-block-template/0013-get-block-template.md

Reproduced in: https: //www.jianshu.com/p/9fb5b406d739

Guess you like

Origin blog.csdn.net/weixin_33971205/article/details/91246438