Class: RecordsKeeperRubyLib::Assets
- Inherits:
-
Object
- Object
- RecordsKeeperRubyLib::Assets
- Defined in:
- lib/RecordsKeeperRubyLib/assets.rb
Class Method Summary collapse
-
.createAsset(address, asset_name, asset_qty) ⇒ Object
Function to create or issue an asset.
-
.retrieveAssets ⇒ Object
Function to retrieve assets information.
-
.sendasset(address, asset_name, asset_qty) ⇒ Object
Function to send assets to an address.
Class Method Details
.createAsset(address, asset_name, asset_qty) ⇒ Object
Function to create or issue an asset
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/RecordsKeeperRubyLib/assets.rb', line 36 def self.createAsset address, asset_name, asset_qty auth = {:username => @user, :password => @password} = { :headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"}, :basic_auth => auth, :body => [ {"method":"issue","params":[address, asset_name, asset_qty],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json } response = HTTParty.get(@url, ) out = response.parsed_response check = out[0]['result'] if check == nil txid = out[0]['error']['message'] else txid = out[0]['result'] end return txid; # Variable to store issue transaction id end |
.retrieveAssets ⇒ Object
Function to retrieve assets information
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/RecordsKeeperRubyLib/assets.rb', line 56 def self.retrieveAssets asset_name = [] issue_id = [] issue_qty = [] auth = {:username => @user, :password => @password} = { :headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"}, :basic_auth => auth, :body => [ {"method":"listassets","params":[],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json } response = HTTParty.get(@url, ) out = response.parsed_response asset_count = out[0]['result'].length # Returns assets count for i in 0...asset_count asset_name.push(out[0]['result'][i]['name']) # Returns asset name issue_id.push(out[0]['result'][i]['issuetxid']) # Returns issue id issue_qty.push(out[0]['result'][i]['issueraw']) # Returns issue quantity end retrieve = {:asset_name => asset_name,:issue_id => issue_id,:issue_qty => issue_qty,:asset_count => asset_count} retrievedinfo = JSON.generate retrieve return retrievedinfo end |
.sendasset(address, asset_name, asset_qty) ⇒ Object
Function to send assets to an address
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/RecordsKeeperRubyLib/assets.rb', line 80 def self.sendasset address, asset_name, asset_qty auth = {:username => @user, :password => @password} = { :headers => headers= {"Content-Type"=> "application/json","Cache-Control" => "no-cache"}, :basic_auth => auth, :body => [ {"method":"sendasset","params":[address, asset_name, asset_qty],"jsonrpc":2.0,"id":"curltext","chain_name":@chain}].to_json } response = HTTParty.get(@url, ) out = response.parsed_response if out[0]['result'].nil? txid = out[0]['error']['message'] else txid = out[0]['result'] end return txid; # Variable to store send asset transaction id end |