Kryvon / KRYVON DEVELOPER DOCSKRYVON DEVELOPER DOCS

Chain (continued)

Use the chain (continued) reference for the Kryvon node, with RPC parameters, response types and examples.

RPC reference

Module Chain (continued)

Method get_epoch_by_number

  • get_epoch_by_number(epoch_number)
  • result: EpochView | null

Returns the epoch in the canonical chain with the specific epoch number.

Params
  • epoch_number - Epoch number
Returns

The RPC returns the epoch when epoch_number is less than or equal to the current epoch number returned by get_current_epoch and returns null otherwise.

Because of chain reorganization, for the same epoch_number, this RPC may return null or different epochs in different invocations.

Example

Request

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "get_epoch_by_number",
  "params": [
    "0x0"
  ]
}

Response

{
  "jsonrpc": "2.0",
  "result": {
    "compact_target": "0x1e02cbd3",
    "length": "0xf0",
    "number": "0x0",
    "start_number": "0x0"
  },
  "id": 1
}

Method get_block_economic_state

Returns increased issuance, miner reward, and the total transaction fee of a block.

This RPC returns null if the block is not in the canonical chain.

KRYVON delays KRYVON creation for miners. The output cells in the cellbase of block N are for the miner creating block N - 1 - ProposalWindow.farthest.

In mainnet, ProposalWindow.farthest is 10, so the outputs in block 100 are rewards for miner creating block 89.

Because of the delay, this RPC returns null if the block rewards are not finalized yet. For example, the economic state for block 89 is only available when the number returned by get_tip_block_number is greater than or equal to 100.

Params
  • block_hash - Specifies the block hash which rewards should be analyzed.
Returns

If the block with the hash block_hash is in the canonical chain and its rewards have been finalized, return the block rewards analysis for this block. A special case is that the return value for genesis block is null.

Example

Request

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "get_block_economic_state",
  "params": [
    "0xfc53392312b0f85d23f8bfd7bb33e9a105095acc89f6f579687bb124c2827334"
  ]
}

Response

{
  "jsonrpc": "2.0",
  "result": null,
  "id": 1
}

Method get_transaction_proof

  • get_transaction_proof(tx_hashes, block_hash)
    • tx_hashes: Array< H256 >
    • block_hash: H256 | null
  • result: TransactionProof

Returns a Merkle proof that transactions are included in a block.

Params
  • tx_hashes - Transaction hashes, all transactions must be in the same block
  • block_hash - An optional parameter, if specified, looks for transactions in the block with this hash
Example

Request

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "get_transaction_proof",
  "params": [
    [
      "0xd43a26b1897c98a5917cd7f8af629e2f749ac37142068ef93c11048e208eff42"
    ],
    "0xfc53392312b0f85d23f8bfd7bb33e9a105095acc89f6f579687bb124c2827334"
  ]
}

Response

{
  "jsonrpc": "2.0",
  "result": {
    "block_hash": "0xfc53392312b0f85d23f8bfd7bb33e9a105095acc89f6f579687bb124c2827334",
    "proof": {
      "indices": [
        "0x0"
      ],
      "lemmas": []
    },
    "witnesses_root": "0x2661d1afd106e307b940b4d8a4e420ba63c0a647a913c2b3cc420a6a766a3b2c"
  },
  "id": 1
}

Method verify_transaction_proof

Verifies that a proof points to transactions in a block, returning the transaction hashes it commits to.

Parameters
Example

Request

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "verify_transaction_proof",
  "params": [
    {
      "block_hash": "0xfc53392312b0f85d23f8bfd7bb33e9a105095acc89f6f579687bb124c2827334",
      "proof": {
        "indices": [
          "0x0"
        ],
        "lemmas": []
      },
      "witnesses_root": "0x2661d1afd106e307b940b4d8a4e420ba63c0a647a913c2b3cc420a6a766a3b2c"
    }
  ]
}

Response

{
  "jsonrpc": "2.0",
  "result": [
    "0xd43a26b1897c98a5917cd7f8af629e2f749ac37142068ef93c11048e208eff42"
  ],
  "id": 1
}

Method get_transaction_and_witness_proof

Returns a Merkle proof of transactions' witness included in a block.

Params
  • tx_hashes - Transaction hashes, all transactions must be in the same block
  • block_hash - An optional parameter, if specified, looks for transactions in the block with this hash
Example

Request

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "get_transaction_and_witness_proof",
  "params": [
    [
      "0xd43a26b1897c98a5917cd7f8af629e2f749ac37142068ef93c11048e208eff42"
    ],
    "0xfc53392312b0f85d23f8bfd7bb33e9a105095acc89f6f579687bb124c2827334"
  ]
}

Response

{
  "jsonrpc": "2.0",
  "result": {
    "block_hash": "0xfc53392312b0f85d23f8bfd7bb33e9a105095acc89f6f579687bb124c2827334",
    "transactions_proof": {
      "indices": [
        "0x0"
      ],
      "lemmas": []
    },
    "witnesses_proof": {
      "indices": [
        "0x0"
      ],
      "lemmas": []
    }
  },
  "id": 1
}

Method verify_transaction_and_witness_proof

Verifies that a proof points to transactions in a block, returning the transaction hashes it commits to.

Parameters
Example

Request

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "verify_transaction_and_witness_proof",
  "params": [
    {
      "block_hash": "0xfc53392312b0f85d23f8bfd7bb33e9a105095acc89f6f579687bb124c2827334",
      "transactions_proof": {
        "indices": [
          "0x0"
        ],
        "lemmas": []
      },
      "witnesses_proof": {
        "indices": [
          "0x0"
        ],
        "lemmas": []
      }
    }
  ]
}

Response

{
  "jsonrpc": "2.0",
  "result": [
    "0xd43a26b1897c98a5917cd7f8af629e2f749ac37142068ef93c11048e208eff42"
  ],
  "id": 1
}

Method get_fork_block

Returns the information about a fork block by hash.

Params
  • block_hash - the fork block hash.
  • verbosity - result format which allows 0 and 2. (Optional, the default is 2.)
Returns

The RPC returns a fork block or null. When the RPC returns a block, the block hash must equal to the parameter block_hash.

Please note that due to the technical nature of the peer to peer sync, the RPC may return null or a fork block result on different nodes with same block_hash even they are fully synced to the canonical chain. And because of chain reorganization, for the same block_hash, the RPC may sometimes return null and sometimes return the fork block.

When verbosity is 2, it returns a JSON object as the result. See BlockView for the schema.

When verbosity is 0, it returns a 0x-prefixed hex string as the result. The string encodes the block serialized by molecule using schema table Block.

Example

Request

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "get_fork_block",
  "params": [
    "0xfc53392312b0f85d23f8bfd7bb33e9a105095acc89f6f579687bb124c2827334",
    "0x2"
  ]
}

Response

{
  "jsonrpc": "2.0",
  "result": null,
  "id": 1
}

Method get_consensus

Return various consensus parameters.

Returns

If any hardfork feature has epoch=null, it means the feature will never be activated.

Example

Request

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "get_consensus",
  "params": []
}

Response

{
  "jsonrpc": "2.0",
  "result": {
    "block_reward_halving_interval": "0x180f60",
    "block_version": "0x0",
    "cellbase_maturity": "0x10000000004",
    "epoch_duration_target": "0x3840",
    "genesis_hash": "0xfc53392312b0f85d23f8bfd7bb33e9a105095acc89f6f579687bb124c2827334",
    "id": "kryvon",
    "initial_block_reward": "0x1faa3b500",
    "max_block_bytes": "0x91c08",
    "max_block_cycles": "0xd09dc300",
    "max_block_proposals_limit": "0x5dc",
    "max_supply": "0x69e40906d04a00",
    "max_uncles_num": "0x2",
    "median_time_block_count": "0x25",
    "orphan_rate_target": {
      "denom": "0x28",
      "numer": "0x1"
    },
    "permanent_difficulty_in_dummy": false,
    "premine": "0xaa87bee538000",
    "proposer_reward_ratio": {
      "denom": "0xa",
      "numer": "0x4"
    },
    "sqisign_lock_code_hash": "0x0ab222ccd15b0160e2113b036ffe7a0d4cbcb40ac2fe7454194f381a33bd0d65",
    "supply_cap_enforced": true,
    "tx_proposal_window": {
      "closest": "0x2",
      "farthest": "0xa"
    },
    "tx_version": "0x0",
    "type_id_code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944"
  },
  "id": 1
}

Method get_block_median_time

  • get_block_median_time(block_hash)
  • result: Uint64 | null

Returns the past median time by block hash.

Params
  • block_hash - A median time is calculated for a consecutive block sequence. block_hash indicates the highest block of the sequence.
Returns

When the given block hash is not on the current canonical chain, this RPC returns null; otherwise returns the median time of the consecutive 37 blocks where the given block_hash has the highest height.

Note that the given block is included in the median time. The included block number range is [MAX(block - 36, 0), block].

Example

Request

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "get_block_median_time",
  "params": [
    "0xfc53392312b0f85d23f8bfd7bb33e9a105095acc89f6f579687bb124c2827334"
  ]
}

Response

{
  "jsonrpc": "2.0",
  "result": "0x1a22c0031e0",
  "id": 1
}

Method estimate_cycles

estimate_cycles run a transaction and return the execution consumed cycles.

This method will not check the transaction validity, but only run the lock script and type script and then return the execution cycles.

It is used to estimate how many cycles the scripts consume.

Errors
Example

Use a native SQIsign transaction with a signed witness and current unspent inputs. Save just the transaction object to signed-transaction.json before calling this method.

jq -c '{jsonrpc:"2.0",id:1,method:"estimate_cycles",params:[.]}' signed-transaction.json |
  curl -fsS http://127.0.0.1:8114 -H 'Content-Type: application/json' --data-binary @-

Method get_fee_rate_statics

👎Deprecated since 0.109.0: Please use the RPC method get_fee_rate_statistics instead

Returns the fee_rate statistics of confirmed blocks on the chain

Params
  • target - Specify the number (1 - 101) of confirmed blocks to be counted. If the number is even, automatically add one. If not specified, defaults to 21
Returns

If the query finds the corresponding historical data, the corresponding statistics are returned, containing the mean and median, in quarks per kilo-weight. If not, it returns null.

Example

Use get_fee_rate_statistics in new integrations.

Method get_fee_rate_statistics

Returns the fee_rate statistics of confirmed blocks on the chain

Params
  • target - Specify the number (1 - 101) of confirmed blocks to be counted. If the number is even, automatically add one. If not specified, defaults to 21
Returns

If the query finds the corresponding historical data, the corresponding statistics are returned, containing the mean and median, in quarks per kilo-weight. If not, it returns null.

Example

Request

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "get_fee_rate_statistics",
  "params": []
}

Response

{
  "jsonrpc": "2.0",
  "result": null,
  "id": 1
}