Class: Radiator::SSC::Contracts

Inherits:
BaseSteemSmartContractRPC show all
Defined in:
lib/radiator/ssc/contracts.rb

Overview

Constant Summary

Constants inherited from BaseSteemSmartContractRPC

BaseSteemSmartContractRPC::POST_HEADERS

Instance Method Summary collapse

Methods inherited from BaseSteemSmartContractRPC

#shutdown

Constructor Details

#initialize(options = {}) ⇒ Contracts

Returns a new instance of Contracts.

Parameters:

  • options (::Hash) (defaults to: {})

    The attributes

Options Hash (options):



9
10
11
12
# File 'lib/radiator/ssc/contracts.rb', line 9

def initialize(options = {})
  super
  @url = options[:url] || "#{@root_url}/contracts"
end

Instance Method Details

#contract(name) ⇒ Object

Example using the defaults, backed by Steem Engine:

rpc = Radiator::SSC::Contracts.new
rpc.contract('tokens')

Parameters:

  • name (String)

Returns:

  • the contract specified from the database



21
22
23
# File 'lib/radiator/ssc/contracts.rb', line 21

def contract(name)
  request(method: 'getContract', params: {name: name})
end

#find(options = {}) ⇒ Object

Example using the defaults, backed by Steem Engine:

rpc = Radiator::SSC::Contracts.new
rpc.find(
  contract: "tokens",
  table: "balances",
  query: {
    symbol: "STINGY"
  }
)

Parameters:

  • options (::Hash) (defaults to: {})

    The attributes

Options Hash (options):

  • :contract (String)
  • :table (String)
  • :query (String)
  • :limit (Integer)

    default: 1000

  • :offset (Integer)

    default: 0

  • :descending (Boolean)
  • indexes (::Hash)

    default: empty, an index is an object { index: string, descending: boolean }

Returns:

  • array of objects that match the query from the table of the specified contract



66
67
68
# File 'lib/radiator/ssc/contracts.rb', line 66

def find(options = {})
  request(method: 'find', params: options)
end

#find_one(options = {}) ⇒ Object

Example using the defaults, backed by Steem Engine:

rpc = Radiator::SSC::Contracts.new
rpc.find_one(
  contract: "tokens",
  table: "balances",
  query: {
    symbol: "STINGY",
    account: "inertia"
  }
)

Parameters:

  • options (::Hash) (defaults to: {})

    The attributes

Options Hash (options):

  • :contract (String)
  • :table (String)
  • :query (String)

Returns:

  • the object that matches the query from the table of the specified contract



42
43
44
# File 'lib/radiator/ssc/contracts.rb', line 42

def find_one(options = {})
  request(method: 'findOne', params: options)
end