module Harmony::Api::V1::Blockchain::Block

Public Instance Methods

block_number() click to toggle source
# File lib/harmony/api/v1/blockchain/block.rb, line 44
def block_number
  response(post('blockNumber'))&.to_i(16)
end
get_block_by_hash(block_hash, full_txs: false) click to toggle source
# File lib/harmony/api/v1/blockchain/block.rb, line 13
def get_block_by_hash(block_hash, full_txs: false)
  params = [block_hash, full_txs]
  response(post('getBlockByHash', params: params))
end
get_block_by_number(block_number, full_txs: false) click to toggle source
# File lib/harmony/api/v1/blockchain/block.rb, line 8
def get_block_by_number(block_number, full_txs: false)
  params = [Harmony::Api::Utilities.int_to_hex(block_number), full_txs]
  response(post('getBlockByNumber', params: params))
end
get_block_signers(block_number:) click to toggle source
# File lib/harmony/api/v1/blockchain/block.rb, line 48
def get_block_signers(block_number:)
  params = [Harmony::Api::Utilities.int_to_hex(block_number)]
  response(post('getBlockSigners', params: params))
end
get_block_transaction_count_by_hash(block_hash) click to toggle source
# File lib/harmony/api/v1/blockchain/block.rb, line 31
def get_block_transaction_count_by_hash(block_hash)
  response(post('getBlockTransactionCountByHash', params: [block_hash]))&.to_i(16)
end
get_block_transaction_count_by_number(block_number) click to toggle source
# File lib/harmony/api/v1/blockchain/block.rb, line 35
def get_block_transaction_count_by_number(block_number)
  params = [Harmony::Api::Utilities.int_to_hex(block_number)]
  response(post('getBlockTransactionCountByNumber', params: params))&.to_i(16)
end
get_blocks(start_block, end_block, with_signers: true, full_txs: false) click to toggle source
# File lib/harmony/api/v1/blockchain/block.rb, line 18
def get_blocks(start_block, end_block, with_signers: true, full_txs: false)
  params = [
    Harmony::Api::Utilities.int_to_hex(start_block),
    Harmony::Api::Utilities.int_to_hex(end_block),
    {
      'withSigners' => with_signers,
      'fullTx' => full_txs
    }
  ]

  response(post('getBlocks', params: params))
end
latest_header() click to toggle source
# File lib/harmony/api/v1/blockchain/block.rb, line 40
def latest_header
  response(post('latestHeader'))
end