module TezosClient::RpcInterface::Contracts

Public Instance Methods

balance(contract_id) click to toggle source
# File lib/tezos_client/rpc_interface/contracts.rb, line 17
def balance(contract_id)
  res = get("#{contract_link(contract_id)}/balance")
  res.to_i.from_satoshi
end
big_map_value(big_map_id:, key:, key_type:) click to toggle source
# File lib/tezos_client/rpc_interface/contracts.rb, line 48
def big_map_value(big_map_id:, key:, key_type:)
  expr_key = encode_script_expr(data: key, type: key_type)

  get "/chains/main/blocks/head/context/big_maps/#{big_map_id}/#{expr_key}"
end
contract_big_maps(contract_address) click to toggle source
# File lib/tezos_client/rpc_interface/contracts.rb, line 54
def contract_big_maps(contract_address)
  contract_storage = contract_storage(contract_address)
  storage_type = contract_storage_type(contract_address)

  TezosClient::Tools::FindBigMapsInStorage.run!(
    storage: contract_storage,
    storage_type: storage_type
  )
end
contract_counter(contract_id) click to toggle source
# File lib/tezos_client/rpc_interface/contracts.rb, line 22
def contract_counter(contract_id)
  res = get("#{contract_link(contract_id)}/counter")
  res.to_i
end
contract_detail(contract_id) click to toggle source
# File lib/tezos_client/rpc_interface/contracts.rb, line 13
def contract_detail(contract_id)
  get contract_link(contract_id)
end
contract_manager_key(contract_id) click to toggle source
# File lib/tezos_client/rpc_interface/contracts.rb, line 27
def contract_manager_key(contract_id)
  get "#{contract_link(contract_id)}/manager_key"
end
contract_storage(contract_id) click to toggle source
# File lib/tezos_client/rpc_interface/contracts.rb, line 36
def contract_storage(contract_id)
  get "#{contract_link(contract_id)}/storage"
end
contract_storage_type(contract_id) click to toggle source
# File lib/tezos_client/rpc_interface/contracts.rb, line 31
def contract_storage_type(contract_id)
  contract = contract_detail(contract_id)
  contract[:script][:code].find { |elem| elem[:prim] == "storage" }[:args].first
end
entrypoint(contract_id, entrypoint) click to toggle source
# File lib/tezos_client/rpc_interface/contracts.rb, line 44
def entrypoint(contract_id, entrypoint)
  get("#{contract_link(contract_id)}/entrypoints/#{entrypoint}")
end
entrypoints(contract_id) click to toggle source
# File lib/tezos_client/rpc_interface/contracts.rb, line 40
def entrypoints(contract_id)
  get("#{contract_link(contract_id)}/entrypoints")
end