Module: PWN::Blockchain::ETH

Defined in:
lib/pwn/blockchain/eth.rb

Overview

This plugin interacts with BitCoin’s Blockchain API.

Class Method Summary collapse

Class Method Details

.authorsObject

Author(s)

0day Inc. <[email protected]>



139
140
141
142
143
# File 'lib/pwn/blockchain/eth.rb', line 139

public_class_method def self.authors
  "AUTHOR(S):
    0day Inc. <[email protected]>
  "
end

.get_block_details(opts = {}) ⇒ Object

Supported Method Parameters

PWN::Blockchain::ETH.get_block_details(

height: 'required - block height number',
token: 'optional - API token for higher rate limits'

)



124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/pwn/blockchain/eth.rb', line 124

public_class_method def self.get_block_details(opts = {})
  height = opts[:height]
  params = {}
  params[:token] = opts[:token] if opts[:token]

  rest_call = "main/blocks/#{height}"
  response = eth_rest_call(rest_call: rest_call, params: params)

  JSON.parse(response.body, symbolize_names: true)
rescue StandardError => e
  raise e
end

.get_latest_block(opts = {}) ⇒ Object

Supported Method Parameters

latest_block = PWN::Blockchain::ETH.get_latest_block(

token: 'optional - API token for higher rate limits'

)



107
108
109
110
111
112
113
114
115
116
117
# File 'lib/pwn/blockchain/eth.rb', line 107

public_class_method def self.get_latest_block(opts = {})
  params = {}
  params[:token] = opts[:token] if opts[:token]

  rest_call = 'main'
  response = eth_rest_call(rest_call: rest_call, params: params)

  JSON.parse(response.body, symbolize_names: true)
rescue StandardError => e
  raise e
end

.helpObject

Display Usage for this Module



147
148
149
150
151
152
153
154
155
156
157
# File 'lib/pwn/blockchain/eth.rb', line 147

public_class_method def self.help
  puts "USAGE:
    latest_block = #{self}.get_latest_block

    block_details = #{self}.get_block_details(
      height: 'required - block height number'
    )

    #{self}.authors
  "
end