Class: Klaytn::JsonRpc
Constant Summary collapse
- BASE_URL =
'https://node-api.klaytnapi.com/v1/klaytn'.freeze
Constants inherited from Base
Base::FUNCTION_NOT_FOUND, Base::INVALID_CLIENT, Base::MISSING_ABI, Base::MISSING_ACCOUNT_POOL_KRN, Base::MISSING_ACCOUNT_WALLET, Base::MISSING_CONTRACT, Base::MISSING_JSONRPC_METHOD, Base::MISSING_KAS_CREDS
Instance Attribute Summary
Attributes inherited from Client
#basic_auth, #chain_id, #contract_address, #headers
Instance Method Summary collapse
Methods inherited from Client
#initialize, #setup_basic_auth, #setup_chain_id
Constructor Details
This class inherits a constructor from Klaytn::Client
Instance Method Details
#function_body_builder(opts) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/klaytn/json_rpc.rb', line 13 def function_body_builder(opts) { id: opts[:id] || 1, jsonrpc: opts[:jsonrpc_version] || "2.0", method: opts[:method], # => klay_isContractAccount params: opts[:params] # => ["0x4319c81f7894f60c70600cf29ee440ed62e7401e", "earliest"] } end |
#invoke_function(opts) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/klaytn/json_rpc.rb', line 5 def invoke_function(opts) raise MISSING_JSONRPC_METHOD if opts[:method].blank? body = function_body_builder(opts) resp = HTTParty.post(BASE_URL, body: body.to_json, headers: headers.merge('content-type' => 'application/json'), basic_auth: basic_auth) JSON.parse(resp.body) end |