class Radiator::SSC::Contracts

The “contracts” endpoint

See: github.com/harpagon210/steemsmartcontracts/wiki/JSON-RPC-server#3-the-contracts-endpoint-httplocalhost5000contracts

Public Class Methods

new(options = {}) click to toggle source

@param options [::Hash] The attributes @option options [String] :url Specify the full node end-point. Default: api.steem-engine.com/rpc/contracts

# File lib/radiator/ssc/contracts.rb, line 9
def initialize(options = {})
  super
  @url = options[:url] || "#{@root_url}/contracts"
end

Public Instance Methods

contract(name) click to toggle source

Example using the defaults, backed by Steem Engine:

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

@param [String] name @return the contract specified from the database

# File lib/radiator/ssc/contracts.rb, line 21
def contract(name)
  request(method: 'getContract', params: {name: name})
end
find(options = {}) click to toggle source

Example using the defaults, backed by Steem Engine:

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

@param options [::Hash] The attributes @option options [String] :contract @option options [String] :table @option options [String] :query @option options [Integer] :limit default: 1000 @option options [Integer] :offset default: 0 @option options [Boolean] :descending @option options [::Hash] indexes default: empty, an index is an object { index: string, descending: boolean } @return array of objects that match the query from the table of the specified contract

# File lib/radiator/ssc/contracts.rb, line 66
def find(options = {})
  request(method: 'find', params: options)
end
find_one(options = {}) click to toggle source

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"
  }
)

@param options [::Hash] The attributes @option options [String] :contract @option options [String] :table @option options [String] :query @return the object that matches the query from the table of the specified contract

# File lib/radiator/ssc/contracts.rb, line 42
def find_one(options = {})
  request(method: 'findOne', params: options)
end

Protected Instance Methods

healthy?() click to toggle source
# File lib/radiator/ssc/contracts.rb, line 70
def healthy?
  begin
    request(method: 'find', params: {
      contract: 'tokens',
      table: 'transfers',
      query: {
        symbol: ''
      },
      limit: 0
    }, skip_health_check: true).nil?
  rescue => e
    warn("Health check for #{uri.inspect} failed: #{e.inspect}")
    
    !!shutdown
  end
end