Class: Bytom::Asset

Inherits:
Object
  • Object
show all
Defined in:
lib/bytom/api/asset.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Asset

Returns a new instance of Asset.



6
7
8
# File 'lib/bytom/api/asset.rb', line 6

def initialize(client)
  @client = client
end

Instance Method Details

#create_asset(alias_name:, definition: {}, root_xpubs: [], quorum: 1, issuance_program: nil) ⇒ Hash

Create asset definition, it prepares for the issuance of asset.

Parameters:

  • alias_name (String)
  • definition (Hash) (defaults to: {})
  • root_xpubs (Array) (defaults to: [])
  • quorum (Fixnum) (defaults to: 1)
  • issuance_program (String) (defaults to: nil)

Returns:

  • (Hash)


21
22
23
24
25
26
27
28
29
# File 'lib/bytom/api/asset.rb', line 21

def create_asset(alias_name:, definition: {}, root_xpubs: [], quorum: 1, issuance_program: nil)
  params = {
      alias: alias_name,
      definition: definition,
  }
  params.merge!(issuance_program: issuance_program) if issuance_program
  params.merge!(root_xpubs: root_xpubs, quorum: quorum) if not root_xpubs.empty?
  client.make_request('/create-asset', 'post', params: params)
end

#get_asset(id:) ⇒ Object

Query detail asset by asset ID.

Parameters:

  • id (String)


36
37
38
39
40
41
# File 'lib/bytom/api/asset.rb', line 36

def get_asset(id:)
  params = {
      id: id
  }
  client.make_request('/get-asset', 'post', params: params)
end

#list_assetsObject

Returns the list of all available assets.



45
46
47
# File 'lib/bytom/api/asset.rb', line 45

def list_assets
  client.make_request('/list-assets', 'post', params: {})
end

#update_asset_alias(id:, alias_name:) ⇒ Object

Update asset alias by assetID.

Parameters:

  • id (String)
  • alias_name (String)


55
56
57
58
59
60
61
# File 'lib/bytom/api/asset.rb', line 55

def update_asset_alias(id:, alias_name:)
  params = {
      id: id,
      alias: alias_name
  }
  client.make_request('/update-asset-alias', 'post', params: params)
end