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: []) ⇒ Object
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
73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/neb/client/api.rb', line 73 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
92 93 94 |
# File 'lib/neb/client/api.rb', line 92 def get_dynasty(height:) send_request(:post, "/dynasty", height: height) end |
#get_events_by_hash(hash:) ⇒ Object
88 89 90 |
# File 'lib/neb/client/api.rb', line 88 def get_events_by_hash(hash:) send_request(:post, "/getEventsByHash", hash: hash) end |
#get_gas_price ⇒ Object Also known as: gas_price
68 69 70 |
# File 'lib/neb/client/api.rb', line 68 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: []) ⇒ Object
64 65 66 |
# File 'lib/neb/client/api.rb', line 64 def subscribe(topics: []) send_request(:post, "/subscribe", topics: topics) end |