Class: Neb::Client::API
- Inherits:
-
Object
- Object
- Neb::Client::API
- Defined in:
- lib/neb/client/api.rb
Instance Attribute Summary collapse
-
#api_version ⇒ Object
readonly
Returns the value of attribute api_version.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
Instance Method Summary collapse
- #call(from:, to:, value:, nonce:, gas_price: 1_000_000, gas_limit: 20_000, contract: nil) ⇒ Object
- #estimate_gas(from:, to:, value:, nonce:, gas_price: 1_000_000, gas_limit: 20_000, contract: nil, binary: nil) ⇒ Object
- #get_account_state(address:, height: 0) ⇒ Object
- #get_block_by_hash(hash:, is_full: true) ⇒ Object
- #get_block_by_height(height:, is_full: true) ⇒ Object
- #get_dynasty(height:) ⇒ Object
- #get_events_by_hash(hash:) ⇒ Object
- #get_gas_price ⇒ Object (also: #gas_price)
- #get_neb_state ⇒ Object
- #get_transaction_by_contract(address:) ⇒ Object
- #get_transaction_receipt(hash:) ⇒ Object
-
#initialize ⇒ API
constructor
A new instance of API.
- #latest_irreversible_block ⇒ Object
- #send_raw_transaction(data:) ⇒ Object
-
#subscribe(topics:, on_download_progress:) ⇒ Object
topics: [“chain.pendingTransaction”] on_download_progress: ->(chunk) { print(chunk) }.
Constructor Details
Instance Attribute Details
#api_version ⇒ Object (readonly)
Returns the value of attribute api_version.
10 11 12 |
# File 'lib/neb/client/api.rb', line 10 def api_version @api_version end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
10 11 12 |
# File 'lib/neb/client/api.rb', line 10 def endpoint @endpoint end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
10 11 12 |
# File 'lib/neb/client/api.rb', line 10 def host @host end |
Instance Method Details
#call(from:, to:, value:, nonce:, gas_price: 1_000_000, gas_limit: 20_000, contract: nil) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# 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) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# 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) ⇒ Object
26 27 28 |
# 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) ⇒ Object
48 49 50 |
# 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) ⇒ Object
52 53 54 |
# 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:) ⇒ Object
94 95 96 |
# File 'lib/neb/client/api.rb', line 94 def get_dynasty(height:) send_request(:post, "/dynasty", height: height) end |
#get_events_by_hash(hash:) ⇒ Object
90 91 92 |
# File 'lib/neb/client/api.rb', line 90 def get_events_by_hash(hash:) send_request(:post, "/getEventsByHash", hash: hash) end |
#get_gas_price ⇒ Object Also known as: gas_price
70 71 72 |
# File 'lib/neb/client/api.rb', line 70 def get_gas_price send_request(:get, "/getGasPrice") end |
#get_neb_state ⇒ Object
18 19 20 |
# File 'lib/neb/client/api.rb', line 18 def get_neb_state send_request(:get, "/nebstate") end |
#get_transaction_by_contract(address:) ⇒ Object
60 61 62 |
# 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:) ⇒ Object
56 57 58 |
# File 'lib/neb/client/api.rb', line 56 def get_transaction_receipt(hash:) send_request(:post, "/getTransactionReceipt", hash: hash) end |
#latest_irreversible_block ⇒ Object
22 23 24 |
# File 'lib/neb/client/api.rb', line 22 def latest_irreversible_block send_request(:get, "/lib") end |
#send_raw_transaction(data:) ⇒ Object
44 45 46 |
# 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:) ⇒ Object
topics: [“chain.pendingTransaction”] on_download_progress: ->(chunk) { print(chunk) }
66 67 68 |
# File 'lib/neb/client/api.rb', line 66 def subscribe(topics:, on_download_progress:) send_request(:post, "/subscribe", { topics: topics }, on_download_progress) end |