Module: BlocksEndpoints

Extended by:
Params, Request
Included in:
Blockfrostruby::CardanoMainNet
Defined in:
lib/blockfrostruby/endpoints/cardano/blocks_endpoints.rb

Constant Summary

Constants included from Blockfrostruby

Blockfrostruby::VERSION

Instance Method Summary collapse

Methods included from Request

get_response, post_file, post_request_cbor, post_request_raw

Methods included from Params

define_params

Methods included from Validator

validate_init_params, validate_params

Methods included from Configuration

default_config, define_config

Instance Method Details

#get_block(hash_or_number) ⇒ Hash

Calls get request on (@url)/blocks/(hash_or_number).

Parameters:

  • hash_or_number (String)

    will be added to the url for get request.

Returns:

  • (Hash)

    formatted result with status and body keys.



34
35
36
# File 'lib/blockfrostruby/endpoints/cardano/blocks_endpoints.rb', line 34

def get_block(hash_or_number)
  Request.get_response("#{@url}/blocks/#{hash_or_number}", @project_id)
end

#get_block_in_slot(slot_number) ⇒ Hash

Calls get request on (@url)/blocks/slot/(slot_number).

Parameters:

  • slot_number (String)

    will be added to the url for get request.

Returns:

  • (Hash)

    formatted result with status and body keys.



42
43
44
# File 'lib/blockfrostruby/endpoints/cardano/blocks_endpoints.rb', line 42

def get_block_in_slot(slot_number)
  Request.get_response("#{@url}/blocks/slot/#{slot_number}", @project_id)
end

#get_block_in_slot_in_epoch(slot_number, epoch_number) ⇒ Hash

Calls get request on (@url)/blocks/epoch/(epoch_number)/slot/(slot_number).

Parameters:

  • slot_number (String)

    will be added to the url for get request.

  • epoch_number (String)

    will be added to the url for get request.

Returns:

  • (Hash)

    formatted result with status and body keys.



51
52
53
# File 'lib/blockfrostruby/endpoints/cardano/blocks_endpoints.rb', line 51

def get_block_in_slot_in_epoch(slot_number, epoch_number)
  Request.get_response("#{@url}/blocks/epoch/#{epoch_number}/slot/#{slot_number}", @project_id)
end

#get_block_latestHash

Calls get request on (@url)/blocks/latest.

Returns:

  • (Hash)

    formatted result with status and body keys.



17
18
19
# File 'lib/blockfrostruby/endpoints/cardano/blocks_endpoints.rb', line 17

def get_block_latest
  Request.get_response("#{@url}/blocks/latest", @project_id)
end

#get_block_latest_transactions(params = {}) ⇒ Hash

Calls get request on (@url)/blocks/latest/txs.

Parameters:

  • params (Hash) (defaults to: {})
    • params passed by user.

Returns:

  • (Hash)

    formatted result with status and body keys.



25
26
27
28
# File 'lib/blockfrostruby/endpoints/cardano/blocks_endpoints.rb', line 25

def get_block_latest_transactions(params = {})
  params = Params.define_params(params, @config)
  Request.get_response("#{@url}/blocks/latest/txs", @project_id, params)
end

#get_block_transactions(hash_or_number, params = {}) ⇒ Hash

Calls get request on (@url)/blocks/(hash_or_number)/txs.

Parameters:

  • hash_or_number (String)

    will be added to the url for get request.

  • params (Hash) (defaults to: {})
    • params passed by user.

Returns:

  • (Hash)

    formatted result with status and body keys.



80
81
82
83
# File 'lib/blockfrostruby/endpoints/cardano/blocks_endpoints.rb', line 80

def get_block_transactions(hash_or_number, params = {})
  params = Params.define_params(params, @config)
  Request.get_response("#{@url}/blocks/#{hash_or_number}/txs", @project_id, params)
end

#get_list_of_next_blocks(hash_or_number, params = {}) ⇒ Hash

Calls get request on (@url)/blocks/(hash_or_number)/next.

Parameters:

  • hash_or_number (String)

    will be added to the url for get request.

  • params (Hash) (defaults to: {})
    • params passed by user.

Returns:

  • (Hash)

    formatted result with status and body keys.



60
61
62
63
# File 'lib/blockfrostruby/endpoints/cardano/blocks_endpoints.rb', line 60

def get_list_of_next_blocks(hash_or_number, params = {})
  params = Params.define_params(params, @config)
  Request.get_response("#{@url}/blocks/#{hash_or_number}/next", @project_id, params)
end

#get_list_of_previous_blocks(hash_or_number, params = {}) ⇒ Hash

Calls get request on (@url)/blocks/(hash_or_number)/previous.

Parameters:

  • hash_or_number (String)

    will be added to the url for get request.

  • params (Hash) (defaults to: {})
    • params passed by user.

Returns:

  • (Hash)

    formatted result with status and body keys.



70
71
72
73
# File 'lib/blockfrostruby/endpoints/cardano/blocks_endpoints.rb', line 70

def get_list_of_previous_blocks(hash_or_number, params = {})
  params = Params.define_params(params, @config)
  Request.get_response("#{@url}/blocks/#{hash_or_number}/previous", @project_id, params)
end