Class: Neb::Client::Admin
- Inherits:
-
Object
- Object
- Neb::Client::Admin
- Defined in:
- lib/neb/client/admin.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
- #accounts ⇒ Object
- #get_config ⇒ Object
-
#initialize ⇒ Admin
constructor
A new instance of Admin.
- #lock_account(address:) ⇒ Object
- #new_account(passphrase:) ⇒ Object
- #node_info ⇒ Object
- #send_transaction(from:, to:, value:, nonce:, gas_price: 1_000_000, gas_limit: 20_000) ⇒ Object
- #sign_hash(address:, hash:, alg: 1) ⇒ Object
- #sign_transaction_with_passphrase(from:, to:, value:, nonce:, gas_price: 1_000_000, gas_limit: 20_000, type:, contract:, binary:, passphrase:) ⇒ Object
- #start_pprof(listen:) ⇒ Object
- #unlock_account(address:, passphrase:, duration: '30000000000') ⇒ Object
Constructor Details
Instance Attribute Details
#api_version ⇒ Object (readonly)
Returns the value of attribute api_version.
10 11 12 |
# File 'lib/neb/client/admin.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/admin.rb', line 10 def endpoint @endpoint end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
10 11 12 |
# File 'lib/neb/client/admin.rb', line 10 def host @host end |
Instance Method Details
#accounts ⇒ Object
22 23 24 |
# File 'lib/neb/client/admin.rb', line 22 def accounts send_request(:get, "/accounts") end |
#get_config ⇒ Object
83 84 85 |
# File 'lib/neb/client/admin.rb', line 83 def get_config send_request(:get, "/getConfig") end |
#lock_account(address:) ⇒ Object
39 40 41 |
# File 'lib/neb/client/admin.rb', line 39 def lock_account(address:) send_request(:post, "/account/lock", address: address) end |
#new_account(passphrase:) ⇒ Object
26 27 28 |
# File 'lib/neb/client/admin.rb', line 26 def new_account(passphrase:) send_request(:post, "/account/new", passphrase: passphrase) end |
#node_info ⇒ Object
18 19 20 |
# File 'lib/neb/client/admin.rb', line 18 def node_info send_request(:get, "/nodeinfo") end |
#send_transaction(from:, to:, value:, nonce:, gas_price: 1_000_000, gas_limit: 20_000) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/neb/client/admin.rb', line 43 def send_transaction(from:, to:, value:, nonce:, gas_price: 1_000_000, gas_limit: 20_000) 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 } send_request(:post, "/transaction", params) end |
#sign_hash(address:, hash:, alg: 1) ⇒ Object
55 56 57 |
# File 'lib/neb/client/admin.rb', line 55 def sign_hash(address:, hash:, alg: 1) send_request(:post, "/sign/hash", address: address, hash: hash, alg: alg) end |
#sign_transaction_with_passphrase(from:, to:, value:, nonce:, gas_price: 1_000_000, gas_limit: 20_000, type:, contract:, binary:, passphrase:) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/neb/client/admin.rb', line 59 def sign_transaction_with_passphrase(from:, to:, value:, nonce:, gas_price: 1_000_000, gas_limit: 20_000, type:, contract:, binary:, passphrase:) params = { transaction: { from: from, to: to, value: value.to_i, nonce: nonce.to_i, gas_price: gas_price.to_i, gas_limit: gas_limit.to_i, type: type, contract: contract, binary: binary }, passphrase: passphrase } send_request(:post, "/transactionWithPassphrase", params) end |
#start_pprof(listen:) ⇒ Object
79 80 81 |
# File 'lib/neb/client/admin.rb', line 79 def start_pprof(listen:) send_request(:post, "/pprof", listen: listen) end |
#unlock_account(address:, passphrase:, duration: '30000000000') ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/neb/client/admin.rb', line 30 def unlock_account(address:, passphrase:, duration: '30000000000') params = { address: address, passphrase: passphrase, duration: duration } send_request(:post, "/account/unlock", params) end |