Class: ECMBlockchain::Tokens

Inherits:
Object
  • Object
show all
Extended by:
Request, Routes
Defined in:
lib/ecm-blockchain-api/token.rb

Constant Summary

Constants included from Routes

Routes::ASSET_BATCH_URL, Routes::ASSET_URL, Routes::MEMBERS_URL, Routes::TOKENS_URL

Constants included from Request

Request::HTTP_VERBS

Class Method Summary collapse

Methods included from Request

extended, request

Class Method Details

.burn(identity, data) ⇒ Object



19
20
21
22
# File 'lib/ecm-blockchain-api/token.rb', line 19

def burn(identity, data)
  response = request( :delete, "/#{identity}#{TOKENS_URL}/burn", data)
  OpenStruct.new(success: true, details: "Tokens successfully burnt")
end

.create(identity, data) ⇒ Object



7
8
9
# File 'lib/ecm-blockchain-api/token.rb', line 7

def create(identity, data)
  token(request( :post, "/#{identity}#{TOKENS_URL}/mint", data ))
end

.retrieve(identity, kind = 'all') ⇒ Object



11
12
13
# File 'lib/ecm-blockchain-api/token.rb', line 11

def retrieve(identity, kind='all')
  token(request( :get, "/#{identity}#{TOKENS_URL}/#{kind}" ))
end

.total_supplyObject



15
16
17
# File 'lib/ecm-blockchain-api/token.rb', line 15

def total_supply()
  token(request( :get, "/#{TOKENS_URL}"))
end

.transfer(from, to, data) ⇒ Object



24
25
26
27
# File 'lib/ecm-blockchain-api/token.rb', line 24

def transfer(from, to, data)
  data[:transferee] = request( :get, "/#{to}#{TOKENS_URL}/wallet")[:address]
  token(request( :patch, "/#{from}#{TOKENS_URL}/transfer", data ))
end