Get block template
curl --request POST \
--url https://api.kas.fyi/v1/rpc/getBlockTemplate \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"payAddress": "kaspa:qpzpfwcsqsxhxwup26r55fd0ghqlhyugz8cp6y3wxuddc02vcxtjg75pspnwz",
"extraData": "Extra block data"
}
'import requests
url = "https://api.kas.fyi/v1/rpc/getBlockTemplate"
payload = {
"payAddress": "kaspa:qpzpfwcsqsxhxwup26r55fd0ghqlhyugz8cp6y3wxuddc02vcxtjg75pspnwz",
"extraData": "Extra block data"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
payAddress: 'kaspa:qpzpfwcsqsxhxwup26r55fd0ghqlhyugz8cp6y3wxuddc02vcxtjg75pspnwz',
extraData: 'Extra block data'
})
};
fetch('https://api.kas.fyi/v1/rpc/getBlockTemplate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.kas.fyi/v1/rpc/getBlockTemplate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'payAddress' => 'kaspa:qpzpfwcsqsxhxwup26r55fd0ghqlhyugz8cp6y3wxuddc02vcxtjg75pspnwz',
'extraData' => 'Extra block data'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.kas.fyi/v1/rpc/getBlockTemplate"
payload := strings.NewReader("{\n \"payAddress\": \"kaspa:qpzpfwcsqsxhxwup26r55fd0ghqlhyugz8cp6y3wxuddc02vcxtjg75pspnwz\",\n \"extraData\": \"Extra block data\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.kas.fyi/v1/rpc/getBlockTemplate")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"payAddress\": \"kaspa:qpzpfwcsqsxhxwup26r55fd0ghqlhyugz8cp6y3wxuddc02vcxtjg75pspnwz\",\n \"extraData\": \"Extra block data\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.kas.fyi/v1/rpc/getBlockTemplate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"payAddress\": \"kaspa:qpzpfwcsqsxhxwup26r55fd0ghqlhyugz8cp6y3wxuddc02vcxtjg75pspnwz\",\n \"extraData\": \"Extra block data\"\n}"
response = http.request(request)
puts response.read_body{
"block": {
"header": {
"version": 1,
"parentsByLevel": [
[
"0x1234567890abcdef..."
],
[
"0x9876543210fedcba..."
]
],
"hashMerkleRoot": "34e9538fd3225652553930657c3d767d5ccab0fcd545038a69c202e45929dcd6",
"acceptedIdMerkleRoot": "34e9538fd3225652553930657c3d767d5ccab0fcd545038a69c202e45929dcd6",
"utxoCommitment": "34e9538fd3225652553930657c3d767d5ccab0fcd545038a69c202e45929dcd6",
"timestamp": "1638360000000",
"bits": 393216,
"nonce": "12345678901234567890",
"daaScore": "1234567",
"blueWork": "123456789012345",
"blueScore": "1234567",
"pruningPoint": "34e9538fd3225652553930657c3d767d5ccab0fcd545038a69c202e45929dcd6"
},
"transactions": [
{
"version": 0,
"inputs": [
{
"previousOutpoint": {
"transactionId": "fa99f98b8e9b0758100d181eccb35a4c053b8265eccb5a89aadd794e087d9820",
"index": 1
},
"signatureScript": "4123c94e322fd98ce4ba8b2e33b47f2984a2f741ecfea6fb48eb90d209a46b9d58639888a1575a717cb243b006edd720a7153e9a7e63f4539958d0a44eea8bfa9f01",
"sequence": 0,
"sigOpCount": 1
}
],
"outputs": [
{
"value": "100000",
"scriptPublicKey": {
"version": 0,
"script": "208b42bec57f9a538f740b067f947a5b29e04043218a37ff1fa7fb5ee850fd3fd3ac"
}
}
],
"lockTime": 0,
"subnetworkId": "0000000000000000000000000000000000000000",
"gas": "0",
"payload": ""
}
]
}
}Mining
Get block template
Gets a block template for mining purposes.
POST
/
v1
/
rpc
/
getBlockTemplate
Get block template
curl --request POST \
--url https://api.kas.fyi/v1/rpc/getBlockTemplate \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"payAddress": "kaspa:qpzpfwcsqsxhxwup26r55fd0ghqlhyugz8cp6y3wxuddc02vcxtjg75pspnwz",
"extraData": "Extra block data"
}
'import requests
url = "https://api.kas.fyi/v1/rpc/getBlockTemplate"
payload = {
"payAddress": "kaspa:qpzpfwcsqsxhxwup26r55fd0ghqlhyugz8cp6y3wxuddc02vcxtjg75pspnwz",
"extraData": "Extra block data"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
payAddress: 'kaspa:qpzpfwcsqsxhxwup26r55fd0ghqlhyugz8cp6y3wxuddc02vcxtjg75pspnwz',
extraData: 'Extra block data'
})
};
fetch('https://api.kas.fyi/v1/rpc/getBlockTemplate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.kas.fyi/v1/rpc/getBlockTemplate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'payAddress' => 'kaspa:qpzpfwcsqsxhxwup26r55fd0ghqlhyugz8cp6y3wxuddc02vcxtjg75pspnwz',
'extraData' => 'Extra block data'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.kas.fyi/v1/rpc/getBlockTemplate"
payload := strings.NewReader("{\n \"payAddress\": \"kaspa:qpzpfwcsqsxhxwup26r55fd0ghqlhyugz8cp6y3wxuddc02vcxtjg75pspnwz\",\n \"extraData\": \"Extra block data\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.kas.fyi/v1/rpc/getBlockTemplate")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"payAddress\": \"kaspa:qpzpfwcsqsxhxwup26r55fd0ghqlhyugz8cp6y3wxuddc02vcxtjg75pspnwz\",\n \"extraData\": \"Extra block data\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.kas.fyi/v1/rpc/getBlockTemplate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"payAddress\": \"kaspa:qpzpfwcsqsxhxwup26r55fd0ghqlhyugz8cp6y3wxuddc02vcxtjg75pspnwz\",\n \"extraData\": \"Extra block data\"\n}"
response = http.request(request)
puts response.read_body{
"block": {
"header": {
"version": 1,
"parentsByLevel": [
[
"0x1234567890abcdef..."
],
[
"0x9876543210fedcba..."
]
],
"hashMerkleRoot": "34e9538fd3225652553930657c3d767d5ccab0fcd545038a69c202e45929dcd6",
"acceptedIdMerkleRoot": "34e9538fd3225652553930657c3d767d5ccab0fcd545038a69c202e45929dcd6",
"utxoCommitment": "34e9538fd3225652553930657c3d767d5ccab0fcd545038a69c202e45929dcd6",
"timestamp": "1638360000000",
"bits": 393216,
"nonce": "12345678901234567890",
"daaScore": "1234567",
"blueWork": "123456789012345",
"blueScore": "1234567",
"pruningPoint": "34e9538fd3225652553930657c3d767d5ccab0fcd545038a69c202e45929dcd6"
},
"transactions": [
{
"version": 0,
"inputs": [
{
"previousOutpoint": {
"transactionId": "fa99f98b8e9b0758100d181eccb35a4c053b8265eccb5a89aadd794e087d9820",
"index": 1
},
"signatureScript": "4123c94e322fd98ce4ba8b2e33b47f2984a2f741ecfea6fb48eb90d209a46b9d58639888a1575a717cb243b006edd720a7153e9a7e63f4539958d0a44eea8bfa9f01",
"sequence": 0,
"sigOpCount": 1
}
],
"outputs": [
{
"value": "100000",
"scriptPublicKey": {
"version": 0,
"script": "208b42bec57f9a538f740b067f947a5b29e04043218a37ff1fa7fb5ee850fd3fd3ac"
}
}
],
"lockTime": 0,
"subnetworkId": "0000000000000000000000000000000000000000",
"gas": "0",
"payload": ""
}
]
}
}Cost
This endpoint costs 0.1 RU (Request Units) per call.Authorizations
API key required for authentication. Get your API key at https://developer.kas.fyi
Body
application/json
Response
200 - application/json
Block template retrieved successfully
Raw block template for mining
Show child attributes
Show child attributes
⌘I