class Neb::Client::API
Attributes
api_version[R]
endpoint[R]
host[R]
Public Class Methods
new()
click to toggle source
# File lib/neb/client/api.rb, line 12 def initialize @host = CONFIG[:host] @api_version = CONFIG[:api_version] @endpoint = CONFIG[:api_endpoint] end
Public Instance Methods
call(from:, to:, value:, nonce:, gas_price: 1_000_000, gas_limit: 20_000, contract: nil)
click to toggle source
# File lib/neb/client/api.rb, line 30 def call(from:, to:, value:, nonce:, gas_price: 1_000_000, gas_limit: 20_000, contract: nil) params = { from: from, to: to, value: value.to_i, nonce: nonce.to_i, gas_price: gas_price.to_i, gas_limit: gas_limit.to_i, contract: contract } send_request(:post, "/call", params) end
estimate_gas(from:, to:, value:, nonce:, gas_price: 1_000_000, gas_limit: 20_000, contract: nil, binary: nil)
click to toggle source
# File lib/neb/client/api.rb, line 75 def estimate_gas(from:, to:, value:, nonce:, gas_price: 1_000_000, gas_limit: 20_000, contract: nil, binary: nil) params = { from: from, to: to, value: value.to_i, nonce: nonce.to_i, gas_price: gas_price.to_i, gas_limit: gas_limit.to_i, contract: contract, binary: binary } send_request(:post, "/estimateGas", params) end
get_account_state(address: , height: 0)
click to toggle source
# File lib/neb/client/api.rb, line 26 def get_account_state(address: , height: 0) send_request(:post, "/accountstate", address: address, height: height) end
get_block_by_hash(hash:, is_full: true)
click to toggle source
# File lib/neb/client/api.rb, line 48 def get_block_by_hash(hash:, is_full: true) send_request(:post, "/getBlockByHash", hash: hash, full_fill_transaction: is_full) end
get_block_by_height(height:, is_full: true)
click to toggle source
# File lib/neb/client/api.rb, line 52 def get_block_by_height(height:, is_full: true) send_request(:post, "/getBlockByHeight", height: height, full_fill_transaction: is_full) end
get_dynasty(height:)
click to toggle source
# File lib/neb/client/api.rb, line 94 def get_dynasty(height:) send_request(:post, "/dynasty", height: height) end
get_events_by_hash(hash:)
click to toggle source
# File lib/neb/client/api.rb, line 90 def get_events_by_hash(hash:) send_request(:post, "/getEventsByHash", hash: hash) end
get_gas_price()
click to toggle source
# File lib/neb/client/api.rb, line 70 def get_gas_price send_request(:get, "/getGasPrice") end
Also aliased as: gas_price
get_neb_state()
click to toggle source
# File lib/neb/client/api.rb, line 18 def get_neb_state send_request(:get, "/nebstate") end
get_transaction_by_contract(address:)
click to toggle source
# File lib/neb/client/api.rb, line 60 def get_transaction_by_contract(address:) send_request(:post, "/getTransactionByContract", address: address) end
get_transaction_receipt(hash:)
click to toggle source
# File lib/neb/client/api.rb, line 56 def get_transaction_receipt(hash:) send_request(:post, "/getTransactionReceipt", hash: hash) end
latest_irreversible_block()
click to toggle source
# File lib/neb/client/api.rb, line 22 def latest_irreversible_block send_request(:get, "/lib") end
send_raw_transaction(data:)
click to toggle source
# File lib/neb/client/api.rb, line 44 def send_raw_transaction(data:) send_request(:post, "/rawtransaction", data: data) end
subscribe(topics:, on_download_progress:)
click to toggle source
topics: [“chain.pendingTransaction”] on_download_progress: ->(chunk) { print(chunk) }
# File lib/neb/client/api.rb, line 66 def subscribe(topics:, on_download_progress:) send_request(:post, "/subscribe", { topics: topics }, on_download_progress) end
Private Instance Methods
send_request(action, url, payload = {}, block = nil)
click to toggle source
# File lib/neb/client/api.rb, line 100 def send_request(action, url, payload = {}, block = nil) request_url = host + api_version + endpoint + url Request.new(action, request_url, payload, block).execute end