Introduction

The Colu engine provides infrastructure for developers seeking to issue and manage their own currency on top of the Bitcoin blockchain (and other blockchains in the future) - all with one SDK.

This platform utilizes the Colored Coins protocol and provides developers with an easy to use API/SDK which are intended to lower the technical barriers required for building currency based applications.

Using the Colu engine requires no prior knowledge of Bitcoin.

GET API KEY

 
Navigation

Products

Colu developers platform contains two products:

1. Colu SDK

Colu SDK is a fully decentralized solution that gives you the functionality of managing digital assets (issue & send), handles bitcoin addresses (hdwallet), it uses Colu Engine for funding all transactions, automatically sign and writes all transactions to the bitcoin blockchain, and reads all digital assets data.
All private keys are stored at the SDK (i.e. at the client side), which makes it highly secure, and all cryptography signings are done by the SDK with fast execution.

2. Colu API

Colu API is a restful API for managing and read digital assets on the customer server. It is easy and simple solution for developers.
It gives the same functionality of Colu SDK for programmers that are using other programming languages than Colu SDK (currently, only Node.js).
To use Colu API you first need to deploy, host and run colu-nodejs server.

The documentations for these products are described in detail in the next sections:

Colu SDK

Colu SDK is a fully decentralized solution for managing digital assets.
Using our SDK you can issue and send digital assets, manage Bitcoin addresses and transactions, fund transactions using the Colu Engine and make queries about existing assets.

Addresses and Private Keys are stored by the SDK in a state of the art HD wallet. Transactions are securely signed on the client side.

Colu's SDK is currently available only for Node.JS. More languages coming soon.
Colu's SDK supports the following features:

  • Digital asset issuance and transfer (with an ability to add unlimited metadata)

  • Asset metadata retrieval - read metadata of existing assets

All the Bitcoin related nitty gritty is automatically handled behind the scenes:
  • Funding - No need to hold any bitcoins, issuance and transfer costs are covered by Colu's engine

  • Addresses and Private Keys - Bitcoin HD wallet management (BIP44)

  • Cryptography and Security - cryptographic aspects of signing Bitcoin transactions

You will need an API key to build with the Colu engine on Mainnet, Go here to get your API Key.

Colu SDK can be installed using the node package manager.
Open the command prompt in your project directory and type

To install Colu SDK module, run the npm install command:

npm install --save colu@latest

Initialization on Testnet

Try it with SDK explorer

colu API Documentation

TITLECreate Colu SDK

VERSION0.1.0

METHODColu

Description

This SDK methods is used to create and initialize Colu SDK

Parameters
FieldTypeDescription
settings

JSON

settings data

    network

String

'Testnet' or 'Mainnet'

    apiKey

String

Your API Key (valid for 'Mainnet' only)

    privateSeed(optional)

String

Private seed for base58 private key

    mnemonic(optional)

String

Mnemonic senescence as seed

    coloredCoinsHost(optional)

String

ColoredCoins API address

    coluHost(optional)

String

Colu engine API address

    redisPort(optional)

String

Redis port

    redisHost(optional)

String

Redis host //events: true, //eventsSecure: true,

Initialize Colu SDK on Testnet


var Colu = require('colu')

var settings = {
    network: 'testnet',
    privateSeed: null
}

var colu = new Colu(settings)
colu.on('connect', function () {
    // Your code here
})

colu.init()

Initialize Colu SDK on Testnet


var Colu = require('colu')

var settings = {
    network: 'testnet',
    privateSeed: null
}

var colu = new Colu(settings)
colu.on('connect', function () {
    // Your code here
})

colu.init()

Initialize Colu SDK on Testnet


<html>
  <head>
    <script type="text/javascript" src="colu.client.js"></script>
  </head>
  <body>
    <script>
      var settings = {
        network: 'testnet',
        privateSeed: null
      }

      var colu = new Colu(settings)
      colu.on('connect', function () {
        // Your code here
      })

      colu.init()
   </script>
 </body>
</html>

Initialize Colu SDK on Testnet


var Colu = require('colu')

var settings = {
    network: 'testnet',
    privateSeed: null
}

var colu = new Colu(settings)
colu.on('connect', function () {
    // Your code here
})

colu.init()

Initialization on Mainnet

Try it with SDK explorer

colu API Documentation

TITLECreate Colu SDK

VERSION0.1.0

METHODColu

Description

This SDK methods is used to create and initialize Colu SDK

Parameters
FieldTypeDescription
settings

JSON

settings data

    network

String

'Testnet' or 'Mainnet'

    apiKey

String

Your API Key (valid for 'Mainnet' only)

    privateSeed(optional)

String

Private seed for base58 private key

    mnemonic(optional)

String

Mnemonic senescence as seed

    coloredCoinsHost(optional)

String

ColoredCoins API address

    coluHost(optional)

String

Colu engine API address

    redisPort(optional)

String

Redis port

    redisHost(optional)

String

Redis host //events: true, //eventsSecure: true,

Initialize Colu SDK on Mainnet


var Colu = require('colu')

var apiKey = 'Your API Key'
var settings = {
    apiKey: apiKey,
    network: 'mainnet',
    privateSeed: null
}

var colu = new Colu(settings)
colu.on('connect', function () {
    // Your code here
})

colu.init()

Initialize Colu SDK on Mainnet


var Colu = require('colu')

var apiKey = 'Your API Key'
var settings = {
    apiKey: apiKey,
    network: 'mainnet',
    privateSeed: null
}

var colu = new Colu(settings)
colu.on('connect', function () {
    // Your code here
})

colu.init()

Initialize Colu SDK on Mainnet


<html>
  <head>
    <script type="text/javascript" src="colu.client.js"></script>
  </head>
  <body>
    <script>
      var apiKey = 'Your API Key'
      var settings = {
        apiKey: apiKey,
        network: 'mainnet',
        privateSeed: null
      }

      var colu = new Colu(settings)
      colu.on('connect', function () {
        // Your code here
      })

      colu.init()
   </script>
 </body>
</html>

Initialize Colu SDK on Mainnet


var Colu = require('colu')

var apiKey = 'Your API Key'
var settings = {
    apiKey: apiKey,
    network: 'mainnet',
    privateSeed: null
}

var colu = new Colu(settings)
colu.on('connect', function () {
    // Your code here
})

colu.init()

Get Mnemonic

Try it with SDK explorer

getMnemonic API Documentation

TITLEGet Mnemonic

VERSION0.1.0

METHODhdwallet.getMnemonic

Description

This SDK methods is used to get the wallet mnemonic senescence

Success
FieldTypeDescription
mnemonic

String

senescence

Get Mnemonic


var Colu = require('colu')

var settings = {
    network: 'testnet'
}

var colu = new Colu(settings)
colu.on('connect', function () {
var mnemonic = colu.hdwallet.getMnemonic()
console.log("mnemonic: ", mnemonic) }); colu.init()

response


mnemonic: state convince method grab route rain phone model february dry layer build

Get Mnemonic


var Colu = require('colu')

var settings = {
    network: 'testnet'
}

var colu = new Colu(settings)
colu.on('connect', function () {
var mnemonic = colu.hdwallet.getMnemonic()
console.log("mnemonic: ", mnemonic) }); colu.init()

response


mnemonic: state convince method grab route rain phone model february dry layer build

Get Mnemonic


<html>
 <head>
   <script type="text/javascript" src="colu.client.js"></script>
 </head>
 <body>
   <script>
     var settings = {
       network: 'testnet'
     }

     var colu = new Colu(settings)
     colu.on('connect', function () {
var mnemonic = colu.hdwallet.getMnemonic()
console.log("mnemonic: ", mnemonic) }); colu.init() </script> </body> </html>

response


mnemonic: state convince method grab route rain phone model february dry layer build

Get Mnemonic


var Colu = require('colu')

var settings = {
    network: 'testnet'
}

var colu = new Colu(settings)
colu.on('connect', function () {
var mnemonic = colu.hdwallet.getMnemonic()
console.log("mnemonic: ", mnemonic) }); colu.init()

response


mnemonic: state convince method grab route rain phone model february dry layer build

Get Private Seed

Try it with SDK explorer

getPrivateSeed API Documentation

TITLEGet Private Seed

VERSION0.1.0

METHODhdwallet.getPrivateSeed

Description

This SDK methods is used to get the wallet private seed

Success
FieldTypeDescription
privateSeed

String

Wallet private seed

Get Private Seed


var Colu = require('colu')

var settings = {
    network: 'testnet',
    privateSeed: null
}

var colu = new Colu(settings)
colu.on('connect', function () {
var privateSeed = colu.hdwallet.getPrivateSeed()
console.log("privateSeed: ", privateSeed) }); colu.init()

response


privateSeed: 1af0d2500cee79344a84bcf374c04b85835390d8a3e8565e594d307a28efb656

Get Private Seed


var Colu = require('colu')

var settings = {
    network: 'testnet',
    privateSeed: null
}

var colu = new Colu(settings)
colu.on('connect', function () {
var privateSeed = colu.hdwallet.getPrivateSeed()
console.log("privateSeed: ", privateSeed) }); colu.init()

response


privateSeed: 1af0d2500cee79344a84bcf374c04b85835390d8a3e8565e594d307a28efb656

Get Private Seed


<html>
 <head>
   <script type="text/javascript" src="colu.client.js"></script>
 </head>
 <body>
   <script>
     var settings = {
       network: 'testnet',
       privateSeed: null
     }

     var colu = new Colu(settings)
     colu.on('connect', function () {
var privateSeed = colu.hdwallet.getPrivateSeed()
console.log("privateSeed: ", privateSeed) }); colu.init() </script> </body> </html>

response


privateSeed: 1af0d2500cee79344a84bcf374c04b85835390d8a3e8565e594d307a28efb656

Get Private Seed


var Colu = require('colu')

var settings = {
    network: 'testnet',
    privateSeed: null
}

var colu = new Colu(settings)
colu.on('connect', function () {
var privateSeed = colu.hdwallet.getPrivateSeed()
console.log("privateSeed: ", privateSeed) }); colu.init()

response


privateSeed: 1af0d2500cee79344a84bcf374c04b85835390d8a3e8565e594d307a28efb656

Get Address

Try it with SDK explorer

getAddress API Documentation

TITLEGet Address

VERSION0.1.0

METHODhdwallet.getAddress

Description

This SDK methods is used to get the wallet address

Success
FieldTypeDescription
address

String

Base58 addres

Get Address


var Colu = require('colu')

var settings = {
    network: 'testnet',
    privateSeed: null
}

var colu = new Colu(settings)
colu.on('connect', function () {
var address = colu.hdwallet.getAddress()
console.log("address: ", address) }) colu.init()

response


address: mj5kxkcec992pDkxveqrgiYJUTUVMFbqys

Get Address


var Colu = require('colu')

var settings = {
    network: 'testnet',
    privateSeed: null
}

var colu = new Colu(settings)
colu.on('connect', function () {
var address = colu.hdwallet.getAddress()
console.log("address: ", address) }) colu.init()

response


address: mj5kxkcec992pDkxveqrgiYJUTUVMFbqys

Get Address


<html>
 <head>
   <script type="text/javascript" src="colu.client.js"></script>
 </head>
 <body>
   <script>
     var settings = {
       network: 'testnet',
       privateSeed: null
     }

     var colu = new Colu(settings)
     colu.on('connect', function () {
var address = colu.hdwallet.getAddress()
console.log("address: ", address) }) colu.init() </script> </body> </html>

response


address: mj5kxkcec992pDkxveqrgiYJUTUVMFbqys

Get Address


var Colu = require('colu')

var settings = {
    network: 'testnet',
    privateSeed: null
}

var colu = new Colu(settings)
colu.on('connect', function () {
var address = colu.hdwallet.getAddress()
console.log("address: ", address) }) colu.init()

response


address: mj5kxkcec992pDkxveqrgiYJUTUVMFbqys

Issue Asset

Try it with SDK explorer

issueAsset API Documentation

TITLERequest to issue a digital asset

VERSION0.1.0

METHODissueAsset

Description

This SDK methods is used to issue assets

Parameters
FieldTypeDescription
amount

Number

Asset amount

issueAddress

String

Base58 public key address of asset issuer

divisibility

Number

Asset divisibility

reissueable

boolean

Define if the asset is unlock

transfer(optional)

JSON[]

Transfer array

    address(optional)

String

Asset transfer address (address | phone number)

    phoneNumber(optional)

String

Asset transfer mobile device number (address | phone number)

    amount

Number

Asset transfer amount

metadata(optional)

Object

Metadata of the specific utxo from the transaction

    assetId(optional)

String

Asset Id

    assetName(optional)

String

Asset Name

    assetGenesis(optional)

String

Genesis transaction where the asset was created (in case of re issue)

    issuer(optional)

String

Name of the issuer

    description(optional)

String

description of the asset

    urls(optional)

Object[]

Array of URL type objects

        name

String

Name of the url

        url

String

The url

        mimeType

String

Mime type of the data in the url

        dataHash(optional)

String

If needed hash of the data that in the url (for proof reasons)

    userData(optional)

JSON

Any arbitrary json data that the pervious owner of the output has entered

rules(optional)

Object

Object for the rules of the asset

    version

Number

Version of the rule system

    fees

Object

        items(optional)

Object[]

Array of fee type items

            address

String

Address to send the fee

            assetId

String

Asset id to send fee (btc if none asset)

            value

Number

Value to send for the fee (in satoshi or amount)

        locked

Boolean

Faild to specify if following transaction of the asset can add to this rule type

    expiration(optional)

Object

Expiration object used to loan an asset, when asset expires it moves back to last output

        validUntil

Number

When the asset is consider expired

        locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

    minters(optional)

Object[]

Array of minter objects, (addresses that can issue the asset)

        address

String

Address of the minter

        locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type (if the minter can add minters)

    holders(optional)

Object[]

Array of holder type objects, they specify in what addresses the asset is considered valid

        address

String

Address where the asset is considered valid

        locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

callback

Object

callback function

Success
FieldTypeDescription
txHex

String

Unsigned transaction hex for the issuance

assetId

String

Asset id for the asset generated

coloredOutputIndexes

Number[]

Asset utxos index numbers array

multisigOutputs

String[]

Multisig outputs of the asset data

txId

String

Transaction id

receivingAddresses

JSON[]

Asset recieving addresses & amounts

    address

String

Address that holds the asset

    amount

Number

Amount of asset on this address

issueAddress

String

Address that issued the asset

issue asset


var Colu = require('colu')

var privateSeed = null

var settings = {
    network: 'testnet',
    privateSeed: privateSeed
}

var colu = new Colu(settings)
colu.on('connect', function () {
    var asset = {
        amount: 10,
        divisibility: 0,
        reissueable: false,
        transfer: [{
            amount: 10
        }],
        metadata: {        
            'assetName': 'Mission Impossible 15',
            'issuer': 'Fox Theater',
            'description': 'Movie ticket to see the New Tom Cruise flick',
            'urls': [{name:'icon', url: 'https://pbs.twimg.com/profile_images/572390580823412736/uzfQSciL_bigger.png', mimeType: 'image/png', dataHash: ''}],
            'userData': {
                'meta' : [
                    {key: 'Item ID', value: 2, type: 'Number'},
                    {key: 'Item Name', value: 'Item Name', type: 'String'},
                    {key: 'Company', value: 'My Company', type: 'String'},
                    {key: 'Address', value: 'San Francisco, CA', type: 'String'}
                ]
            }
        }
    }

colu.issueAsset(asset, function (err, body) {
if (err) return console.error(err) console.log(body) }) }) colu.init()

response

{ 
    txHex: '0100000001d6f4e237992a77f346211f933032347f037b9f0695fcc1cba1f62191d69816ed000000001976a914c8cc9605033d1b9d14c937542aa97027b868b9c288acffffffff04ac0200000000000047512103ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff21038f0bc8fa694b9279ef9a0acdaf846a3d794504abd66173fcd6f87410d479f18752ae58020000000000001976a914c8cc9605033d1b9d14c937542aa97027b868b9c288ac00000000000000001e6a1c434301024096bfdd6313e8bb1c0be60d7bb3f999d60a3f2a0a010a10cc020000000000001976a914c8cc9605033d1b9d14c937542aa97027b868b9c288ac00000000',
    assetId: 'LEuQv9iXrfXAvV8T7BG4ykJeErtF1b28YUjz4',
    coloredOutputIndexes: [ 1 ],
    txid: 'fed1b304174dd74022984ff73bfeeb20ccd464a0994a86a677882426055518cc',
    receivingAddresses: [{ 
        amount: 10, 
        address: 'mypgXJgAAvTZQMZcvMsFA7Q5SYo1Mtyj2a' 
    }],
    issueAddress: 'mypgXJgAAvTZQMZcvMsFA7Q5SYo1Mtyj2a' 
}

issue asset


var Colu = require('colu')

var privateSeed = null

var settings = {
    network: 'testnet',
    privateSeed: privateSeed
}

var colu = new Colu(settings)
colu.on('connect', function () {
    var asset = {
        amount: 10,
        divisibility: 0,
        reissueable: false,
        transfer: [{
            amount: 10
        }],
        metadata: {        
            'assetName': 'Mission Impossible 15',
            'issuer': 'Fox Theater',
            'description': 'Movie ticket to see the New Tom Cruise flick',
            'urls': [{name:'icon', url: 'https://pbs.twimg.com/profile_images/572390580823412736/uzfQSciL_bigger.png', mimeType: 'image/png', dataHash: ''}],
            'userData': {
                'meta' : [
                    {key: 'Item ID', value: 2, type: 'Number'},
                    {key: 'Item Name', value: 'Item Name', type: 'String'},
                    {key: 'Company', value: 'My Company', type: 'String'},
                    {key: 'Address', value: 'San Francisco, CA', type: 'String'}
                ]
            }
        }
    }

colu.issueAsset(asset, function (err, body) {
if (err) return console.error(err) console.log(body) }) }) colu.init()

response

{ 
    txHex: '0100000001d6f4e237992a77f346211f933032347f037b9f0695fcc1cba1f62191d69816ed000000001976a914c8cc9605033d1b9d14c937542aa97027b868b9c288acffffffff04ac0200000000000047512103ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff21038f0bc8fa694b9279ef9a0acdaf846a3d794504abd66173fcd6f87410d479f18752ae58020000000000001976a914c8cc9605033d1b9d14c937542aa97027b868b9c288ac00000000000000001e6a1c434301024096bfdd6313e8bb1c0be60d7bb3f999d60a3f2a0a010a10cc020000000000001976a914c8cc9605033d1b9d14c937542aa97027b868b9c288ac00000000',
    assetId: 'LEuQv9iXrfXAvV8T7BG4ykJeErtF1b28YUjz4',
    coloredOutputIndexes: [ 1 ],
    txid: 'fed1b304174dd74022984ff73bfeeb20ccd464a0994a86a677882426055518cc',
    receivingAddresses: [{ 
        amount: 10, 
        address: 'mypgXJgAAvTZQMZcvMsFA7Q5SYo1Mtyj2a' 
    }],
    issueAddress: 'mypgXJgAAvTZQMZcvMsFA7Q5SYo1Mtyj2a' 
}

issue asset


<html>
 <head>
   <script type="text/javascript" src="colu.client.js"></script>
 </head>
 <body>
   <script>
     var privateSeed = null
     var assetId;

     var settings = {
       network: 'testnet',
       privateSeed: privateSeed
     }

     var colu = new Colu(settings)

     var asset = {
       amount: 10,
       divisibility: 0,
       reissueable: false,
       transfer: [{
           amount: 10
       }],
       metadata: {
         'assetName': 'Mission Impossible 15',
         'issuer': 'Fox Theater',
         'description': 'Movie ticket to see the New Tom Cruise flick',
         'urls': [{name:'icon', url: 'https://pbs.twimg.com/profile_images/572390580823412736/uzfQSciL_bigger.png', mimeType: 'image/png', dataHash: ''}],
         'userData': {
             'meta': [
                 { key: 'Item ID', value: 2, type: 'Number' },
                 { key: 'Item Name', value: 'Item Name', type: 'String' },
                 { key: 'Company', value: 'My Company', type: 'String' },
                 { key: 'Address', value: 'San Francisco, CA', type: 'String' }
             ]
         }
       }
     }

colu.init(function () { colu.issueAsset(asset, function (err, body) {
if (err) return console.error(err) var assetId = body.assetId var privateSeed = colu.hdwallet.getPrivateSeed() console.log('assetId: ', assetId) console.log('PrivateSeed: ', privateSeed) console.log('Body: ', body) }) }) </script> </body> </html>

response

{ 
    txHex: '0100000001d6f4e237992a77f346211f933032347f037b9f0695fcc1cba1f62191d69816ed000000001976a914c8cc9605033d1b9d14c937542aa97027b868b9c288acffffffff04ac0200000000000047512103ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff21038f0bc8fa694b9279ef9a0acdaf846a3d794504abd66173fcd6f87410d479f18752ae58020000000000001976a914c8cc9605033d1b9d14c937542aa97027b868b9c288ac00000000000000001e6a1c434301024096bfdd6313e8bb1c0be60d7bb3f999d60a3f2a0a010a10cc020000000000001976a914c8cc9605033d1b9d14c937542aa97027b868b9c288ac00000000',
    assetId: 'LEuQv9iXrfXAvV8T7BG4ykJeErtF1b28YUjz4',
    coloredOutputIndexes: [ 1 ],
    txid: 'fed1b304174dd74022984ff73bfeeb20ccd464a0994a86a677882426055518cc',
    receivingAddresses: [{ 
        amount: 10, 
        address: 'mypgXJgAAvTZQMZcvMsFA7Q5SYo1Mtyj2a' 
    }],
    issueAddress: 'mypgXJgAAvTZQMZcvMsFA7Q5SYo1Mtyj2a' 
}

issue asset


var Colu = require('colu')

var privateSeed = null

var settings = {
    network: 'testnet',
    privateSeed: privateSeed
}

var colu = new Colu(settings)
colu.on('connect', function () {
    var asset = {
        amount: 10,
        divisibility: 0,
        reissueable: false,
        transfer: [{
            amount: 10
        }],
        metadata: {        
            'assetName': 'Mission Impossible 15',
            'issuer': 'Fox Theater',
            'description': 'Movie ticket to see the New Tom Cruise flick',
            'urls': [{name:'icon', url: 'https://pbs.twimg.com/profile_images/572390580823412736/uzfQSciL_bigger.png', mimeType: 'image/png', dataHash: ''}],
            'userData': {
                'meta' : [
                    {key: 'Item ID', value: 2, type: 'Number'},
                    {key: 'Item Name', value: 'Item Name', type: 'String'},
                    {key: 'Company', value: 'My Company', type: 'String'},
                    {key: 'Address', value: 'San Francisco, CA', type: 'String'}
                ]
            }
        }
    }

colu.issueAsset(asset, function (err, body) {
if (err) return console.error(err) console.log(body) }) }) colu.init()

response

{ 
    txHex: '0100000001d6f4e237992a77f346211f933032347f037b9f0695fcc1cba1f62191d69816ed000000001976a914c8cc9605033d1b9d14c937542aa97027b868b9c288acffffffff04ac0200000000000047512103ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff21038f0bc8fa694b9279ef9a0acdaf846a3d794504abd66173fcd6f87410d479f18752ae58020000000000001976a914c8cc9605033d1b9d14c937542aa97027b868b9c288ac00000000000000001e6a1c434301024096bfdd6313e8bb1c0be60d7bb3f999d60a3f2a0a010a10cc020000000000001976a914c8cc9605033d1b9d14c937542aa97027b868b9c288ac00000000',
    assetId: 'LEuQv9iXrfXAvV8T7BG4ykJeErtF1b28YUjz4',
    coloredOutputIndexes: [ 1 ],
    txid: 'fed1b304174dd74022984ff73bfeeb20ccd464a0994a86a677882426055518cc',
    receivingAddresses: [{ 
        amount: 10, 
        address: 'mypgXJgAAvTZQMZcvMsFA7Q5SYo1Mtyj2a' 
    }],
    issueAddress: 'mypgXJgAAvTZQMZcvMsFA7Q5SYo1Mtyj2a' 
}

Send Asset

Try it with SDK explorer

sendAsset API Documentation

TITLERequest to send a digital asset

VERSION0.1.0

METHODsendAsset

Description

This SDK method is used to send assets between users

Parameters
FieldTypeDescription
from(optional)

String[]

Array of address to send the asset from. Any unspents of the specific asset held by that address may be used (optional can used sendutxo instead)

sendutxo(optional)

String[]

Array of Utxos to use for sending the asset itself (:format)

to

JSON[]

transfer array

    address

String

Asset transfer address (address | phone number)

    phoneNumber

String

Asset transfer mobile device number (address | phone number)

    assetId

String

Asset id

    amount

Number

Asset transfer amount

metadata(optional)

Object

Metadata of the specific utxo from the transaction

    assetId(optional)

String

Asset Id

    assetName(optional)

String

Asset Name

    assetGenesis(optional)

String

Genesis transaction where the asset was created (in case of re issue)

    issuer(optional)

String

Name of the issuer

    description(optional)

String

description of the asset

    urls(optional)

Object[]

Array of URL type objects

        name

String

Name of the url

        url

String

The url

        mimeType

String

Mime type of the data in the url

        dataHash(optional)

String

If needed hash of the data that in the url (for proof reasons)

    userData(optional)

JSON

Any arbitrary json data that the pervious owner of the output has entered

rules(optional)

Object

Object for the rules of the asset

    version

Number

Version of the rule system

    fees

Object

        items(optional)

Object[]

Array of fee type items

            address

String

Address to send the fee

            assetId

String

Asset id to send fee (btc if none asset)

            value

Number

Value to send for the fee (in satoshi or amount)

        locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

    expiration(optional)

Object

Expiration object used to loan an asset, when asset expires it moves back to last output

        validUntil

Number

When the asset is consider expired

        locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

    minters(optional)

Object[]

Array of minter objects, (addresses that can issue the asset)

        address

String

Address of the minter

        locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type (if the minter can add minters)

    holders(optional)

Object[]

Array of holder type objects, they specify in what addresses the asset is considered valid

        address

String

Address where the asset is considered valid

        locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

callback

Object

callback function

Success
FieldTypeDescription
txHex

String

Hex of the transfer transaction

coloredOutputIndexes

Number[]

Asset utxos index numbers array

metadataSha1

String

Hashing data of the asset metadata

multisigOutputs

String[]

Multisig outputs of the asset data

txid

String

The transfer transaction id

financeTxid

String

The finance transaction id

Send Asset


var Colu = require('colu');

var privateSeed = "1d7f034f59ed9150e055f7931f7f7543ed0bb6e551946f407b7171fed2e8b40f";
var settings = {
    "network": "testnet",
    "privateSeed": privateSeed
}

var colu = new Colu(settings)
colu.on('connect', function () {
    var args = {
        "from": ["muUkQk6wBSrshZb52tSos5z5LQvoyLq8EX"],
	"to": [{
            "address": "mkMiyarPHVLy2hNz4vHmtBSmj1qZ1rf2Qg",
            "phoneNumber": "+1234567890",
            "assetId": "La2zJSvLnd1cUZAjhqXsEHBqPJr2Hg6d5kiZ1e",
	    "amount": "1"
	}],
	"metadata": {
	    "assetName": "Mission Impossible 15",
            "issuer": "Fox Theater",
	    "description": "Movie ticket to see the New Tom Cruise flick"
        }
    }

colu.sendAsset(args, function (err, body) {
if (err) return console.error(err) console.log(body) }); }); colu.init();

response

{
	"txHex": "010000000294362d10bffb3c384025e0125ca0c104e88eab46ed5d38e860f55538d688b7db000000001976a9149927021be1079c55c93cdf92fe686f488465367288acffffffff80aea67dde7df68ae1b7f1253a4f954e1981b3ad77b90ae40c024e004fd21b3d000000001976a9149927021be1079c55c93cdf92fe686f488465367288acffffffff0358020000000000001976a914633699e22646cb432a0455344a3771adb4fa883688ac00000000000000003c6a3a43430210108fc023ec679eefac3e01405edf3b8371898dc6fa8296f67ca964e55976b6d9bda64dbbaef92f55ede0928111c8126d1f524d0d000158020000000000001976a9149927021be1079c55c93cdf92fe686f488465367288ac00000000",
	"metadataSha1": "108fc023ec679eefac3e01405edf3b8371898dc6",
	"multisigOutputs": [],
	"coloredOutputIndexes": [
		0
	],
	"financeTxid": "3d1bd24f004e020ce40ab977adb381194e954f3a25f1b7e18af67dde7da6ae80",
	"txid": "8999571e5e1255ffd29eca2eefb2d39afe6b7871e359659e1179b613af591817"
}

Send Asset


var Colu = require('colu');

var privateSeed = "1d7f034f59ed9150e055f7931f7f7543ed0bb6e551946f407b7171fed2e8b40f";
var assetId;
var settings = {
    "network": "testnet",
    "privateSeed": privateSeed
}

var colu = new Colu(settings)
colu.on('connect', function () {
    var args = {
        "from": ["muUkQk6wBSrshZb52tSos5z5LQvoyLq8EX"],
	"to": [{
            "address": "mkMiyarPHVLy2hNz4vHmtBSmj1qZ1rf2Qg",
            "phoneNumber": "+1234567890",
            "assetId": "La2zJSvLnd1cUZAjhqXsEHBqPJr2Hg6d5kiZ1e",
	    "amount": "1"
	}],
	"metadata": {
	    "assetName": "Mission Impossible 15",
            "issuer": "Fox Theater",
	    "description": "Movie ticket to see the New Tom Cruise flick"
        }
    }

colu.sendAsset(args, function (err, body) {
if (err) return console.error(err) console.log(body) }); }); colu.init();

response

{
	"txHex": "010000000294362d10bffb3c384025e0125ca0c104e88eab46ed5d38e860f55538d688b7db000000001976a9149927021be1079c55c93cdf92fe686f488465367288acffffffff80aea67dde7df68ae1b7f1253a4f954e1981b3ad77b90ae40c024e004fd21b3d000000001976a9149927021be1079c55c93cdf92fe686f488465367288acffffffff0358020000000000001976a914633699e22646cb432a0455344a3771adb4fa883688ac00000000000000003c6a3a43430210108fc023ec679eefac3e01405edf3b8371898dc6fa8296f67ca964e55976b6d9bda64dbbaef92f55ede0928111c8126d1f524d0d000158020000000000001976a9149927021be1079c55c93cdf92fe686f488465367288ac00000000",
	"metadataSha1": "108fc023ec679eefac3e01405edf3b8371898dc6",
	"multisigOutputs": [],
	"coloredOutputIndexes": [
		0
	],
	"financeTxid": "3d1bd24f004e020ce40ab977adb381194e954f3a25f1b7e18af67dde7da6ae80",
	"txid": "8999571e5e1255ffd29eca2eefb2d39afe6b7871e359659e1179b613af591817"
}

Send Asset


var Colu = require('colu');

var privateSeed = "1d7f034f59ed9150e055f7931f7f7543ed0bb6e551946f407b7171fed2e8b40f";
var settings = {
    "network": "testnet",
    "privateSeed": privateSeed
}

var colu = new Colu(settings)
colu.on('connect', function () {
    var args = {
        "from": ["muUkQk6wBSrshZb52tSos5z5LQvoyLq8EX"],
	"to": [{
            "address": "mkMiyarPHVLy2hNz4vHmtBSmj1qZ1rf2Qg",
            "phoneNumber": "+1234567890",
            "assetId": "La2zJSvLnd1cUZAjhqXsEHBqPJr2Hg6d5kiZ1e",
	    "amount": "1"
	}],
	"metadata": {
	    "assetName": "Mission Impossible 15",
            "issuer": "Fox Theater",
	    "description": "Movie ticket to see the New Tom Cruise flick"
        }
    }

colu.sendAsset(args, function (err, body) {
if (err) return console.error(err) console.log(body) }); }); colu.init();

response

{
	"txHex": "010000000294362d10bffb3c384025e0125ca0c104e88eab46ed5d38e860f55538d688b7db000000001976a9149927021be1079c55c93cdf92fe686f488465367288acffffffff80aea67dde7df68ae1b7f1253a4f954e1981b3ad77b90ae40c024e004fd21b3d000000001976a9149927021be1079c55c93cdf92fe686f488465367288acffffffff0358020000000000001976a914633699e22646cb432a0455344a3771adb4fa883688ac00000000000000003c6a3a43430210108fc023ec679eefac3e01405edf3b8371898dc6fa8296f67ca964e55976b6d9bda64dbbaef92f55ede0928111c8126d1f524d0d000158020000000000001976a9149927021be1079c55c93cdf92fe686f488465367288ac00000000",
	"metadataSha1": "108fc023ec679eefac3e01405edf3b8371898dc6",
	"multisigOutputs": [],
	"coloredOutputIndexes": [
		0
	],
	"financeTxid": "3d1bd24f004e020ce40ab977adb381194e954f3a25f1b7e18af67dde7da6ae80",
	"txid": "8999571e5e1255ffd29eca2eefb2d39afe6b7871e359659e1179b613af591817"
}

Send Asset


var Colu = require('colu');

var privateSeed = "1d7f034f59ed9150e055f7931f7f7543ed0bb6e551946f407b7171fed2e8b40f";
var settings = {
    "network": "testnet",
    "privateSeed": privateSeed
}

var colu = new Colu(settings)
colu.on('connect', function () {
    var args = {
        "from": ["muUkQk6wBSrshZb52tSos5z5LQvoyLq8EX"],
	"to": [{
            "address": "mkMiyarPHVLy2hNz4vHmtBSmj1qZ1rf2Qg",
            "phoneNumber": "+1234567890",
            "assetId": "La2zJSvLnd1cUZAjhqXsEHBqPJr2Hg6d5kiZ1e",
	    "amount": "1"
	}],
	"metadata": {
	    "assetName": "Mission Impossible 15",
            "issuer": "Fox Theater",
	    "description": "Movie ticket to see the New Tom Cruise flick"
        }
    }

colu.sendAsset(args, function (err, body) {
if (err) return console.error(err) console.log(body) }); }); colu.init();

response

{
	"txHex": "010000000294362d10bffb3c384025e0125ca0c104e88eab46ed5d38e860f55538d688b7db000000001976a9149927021be1079c55c93cdf92fe686f488465367288acffffffff80aea67dde7df68ae1b7f1253a4f954e1981b3ad77b90ae40c024e004fd21b3d000000001976a9149927021be1079c55c93cdf92fe686f488465367288acffffffff0358020000000000001976a914633699e22646cb432a0455344a3771adb4fa883688ac00000000000000003c6a3a43430210108fc023ec679eefac3e01405edf3b8371898dc6fa8296f67ca964e55976b6d9bda64dbbaef92f55ede0928111c8126d1f524d0d000158020000000000001976a9149927021be1079c55c93cdf92fe686f488465367288ac00000000",
	"metadataSha1": "108fc023ec679eefac3e01405edf3b8371898dc6",
	"multisigOutputs": [],
	"coloredOutputIndexes": [
		0
	],
	"financeTxid": "3d1bd24f004e020ce40ab977adb381194e954f3a25f1b7e18af67dde7da6ae80",
	"txid": "8999571e5e1255ffd29eca2eefb2d39afe6b7871e359659e1179b613af591817"
}

Burn Asset

Try it with SDK explorer

burnAsset API Documentation

TITLERequest to burn an asset

VERSION0.1.0

METHODburnAsset

Description

Burn an asset - reduce a specified amount of units of an asset from its total supply.

Parameters
FieldTypeDescription
from(optional)

String[]

Array of addresses to burn (and optionally send) the asset from. Any UTXO of the specific asset held by that address may be used (optional can use sendutxo instead)

sendutxo(optional)

String[]

Array of UTXOs to use for burning (and optionally sending) the asset itself (:format)

burn

JSON[]

burn array

    assetId

String

Asset Id

    amount

Number

Asset burn amount

transfer(optional)

JSON[]

transfer array

    address(optional)

String

Asset transfer address (address | phone number)

    phoneNumber(optional)

String

Asset transfer mobile device number (address | phone number)

    assetId(optional)

String

Asset id

    amount(optional)

Number

Asset transfer amount

metadata(optional)

Object

Metadata of the specific utxo from the transaction

    assetId(optional)

String

Asset Id

    assetName(optional)

String

Asset Name

    assetGenesis(optional)

String

Genesis transaction where the asset was created (in case of re issue)

    issuer(optional)

String

Name of the issuer

    description(optional)

String

description of the asset

    urls(optional)

Object[]

Array of URL type objects

        name

String

Name of the url

        url

String

The url

        mimeType

String

Mime type of the data in the url

        dataHash(optional)

String

If needed hash of the data that in the url (for proof reasons)

    userData(optional)

JSON

Any arbitrary json data that the pervious owner of the output has entered

rules(optional)

Object

Object for the rules of the asset

    version

Number

Version of the rule system

    fees

Object

        items(optional)

Object[]

Array of fee type items

            address

String

Address to send the fee

            assetId

String

Asset id to send fee (btc if none asset)

            value

Number

Value to send for the fee (in satoshi or amount)

        locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

    expiration(optional)

Object

Expiration object used to loan an asset, when asset expires it moves back to last output

        validUntil

Number

When the asset is consider expired

        locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

    minters(optional)

Object[]

Array of minter objects, (addresses that can issue the asset)

        address

String

Address of the minter

        locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type (if the minter can add minters)

    holders(optional)

Object[]

Array of holder type objects, they specify in what addresses the asset is considered valid

        address

String

Address where the asset is considered valid

        locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

callback

Object

callback function

Success
FieldTypeDescription
txHex

String

Hex of the burn transaction

coloredOutputIndexes

Number[]

Asset utxos index numbers array

metadataSha1

String

Hashing data of the asset metadata

multisigOutputs

String[]

Multisig outputs of the asset data

txid

String

The burn transaction id

financeTxid

String

The finance transaction id

Burn Asset


var Colu = require('colu')

var privateSeed = '9a91561ea7b553edec7a7f6d5aed023c99fddcd5e592e85a4fcfed979627acac'
var assetId = 'La8nmmQ7HyVeyWVo4XC9k5rdRzrcjjAw73WgYt'
var fromAddress = 'mvmFwY9gJCtKBdFPDDyCGuYXVCrB6ejScK'

var settings = {
    network: 'testnet',
    privateSeed: privateSeed
}

var colu = new Colu(settings)
colu.on('connect', function () {
    var args = {
        from: [fromAddress],
        burn: [{
            assetId: assetId,
            amount: 2
        }]
    }
	
colu.burnAsset(args, function (err, body) {
if (err) return console.error(err) console.log("Body: ", body) }) }) colu.init()

response

{ txHex: '0100000002346ab93dd39019102a78f64fb462922f8f2fc64f4de382998486ce7dca95428a000000001976a914a73e70ca6fdb743515508a47dd36e922527174b188acffffffffb3630450c091566c99f4807381647f1b440402d086394aa22480664484238b12000000001976a914a73e70ca6fdb743515508a47dd36e922527174b188acffffffff020000000000000000086a06434302251f0258020000000000001976a914a73e70ca6fdb743515508a47dd36e922527174b188ac00000000',
  multisigOutputs: [],
  coloredOutputIndexes: [],
  financeTxid: '128b238444668024a24a3986d00204441b7f64817380f4996c5691c0500463b3',
  txid: '4effebaa539b527a5a1990d8f232eb04fbc4e3966a9834926d451d902993b6cd' }

Burn Asset


var Colu = require('colu')

var privateSeed = '9a91561ea7b553edec7a7f6d5aed023c99fddcd5e592e85a4fcfed979627acac'
var assetId = 'La8nmmQ7HyVeyWVo4XC9k5rdRzrcjjAw73WgYt'
var fromAddress = 'mvmFwY9gJCtKBdFPDDyCGuYXVCrB6ejScK'

var settings = {
    network: 'testnet',
    privateSeed: privateSeed
}

var colu = new Colu(settings)
colu.on('connect', function () {
    var args = {
        from: [fromAddress],
        burn: [{
            assetId: assetId,
            amount: 2
        }]
    }
	
colu.burnAsset(args, function (err, body) {
if (err) return console.error(err) console.log("Body: ", body) }) }) colu.init()

response

{ txHex: '0100000002346ab93dd39019102a78f64fb462922f8f2fc64f4de382998486ce7dca95428a000000001976a914a73e70ca6fdb743515508a47dd36e922527174b188acffffffffb3630450c091566c99f4807381647f1b440402d086394aa22480664484238b12000000001976a914a73e70ca6fdb743515508a47dd36e922527174b188acffffffff020000000000000000086a06434302251f0258020000000000001976a914a73e70ca6fdb743515508a47dd36e922527174b188ac00000000',
  multisigOutputs: [],
  coloredOutputIndexes: [],
  financeTxid: '128b238444668024a24a3986d00204441b7f64817380f4996c5691c0500463b3',
  txid: '4effebaa539b527a5a1990d8f232eb04fbc4e3966a9834926d451d902993b6cd' }

Burn Asset


var Colu = require('colu')

var privateSeed = '9a91561ea7b553edec7a7f6d5aed023c99fddcd5e592e85a4fcfed979627acac'
var assetId = 'La8nmmQ7HyVeyWVo4XC9k5rdRzrcjjAw73WgYt'
var fromAddress = 'mvmFwY9gJCtKBdFPDDyCGuYXVCrB6ejScK'

var settings = {
    network: 'testnet',
    privateSeed: privateSeed
}

var colu = new Colu(settings)
colu.on('connect', function () {
    var args = {
        from: [fromAddress],
        burn: [{
            assetId: assetId,
            amount: 2
        }]
    }
	
colu.burnAsset(args, function (err, body) {
if (err) return console.error(err) console.log("Body: ", body) }) }) colu.init()

response

{ txHex: '0100000002346ab93dd39019102a78f64fb462922f8f2fc64f4de382998486ce7dca95428a000000001976a914a73e70ca6fdb743515508a47dd36e922527174b188acffffffffb3630450c091566c99f4807381647f1b440402d086394aa22480664484238b12000000001976a914a73e70ca6fdb743515508a47dd36e922527174b188acffffffff020000000000000000086a06434302251f0258020000000000001976a914a73e70ca6fdb743515508a47dd36e922527174b188ac00000000',
  multisigOutputs: [],
  coloredOutputIndexes: [],
  financeTxid: '128b238444668024a24a3986d00204441b7f64817380f4996c5691c0500463b3',
  txid: '4effebaa539b527a5a1990d8f232eb04fbc4e3966a9834926d451d902993b6cd' }

Burn Asset


var Colu = require('colu')

var privateSeed = '9a91561ea7b553edec7a7f6d5aed023c99fddcd5e592e85a4fcfed979627acac'
var assetId = 'La8nmmQ7HyVeyWVo4XC9k5rdRzrcjjAw73WgYt'
var fromAddress = 'mvmFwY9gJCtKBdFPDDyCGuYXVCrB6ejScK'

var settings = {
    network: 'testnet',
    privateSeed: privateSeed
}

var colu = new Colu(settings)
colu.on('connect', function () {
    var args = {
        from: [fromAddress],
        burn: [{
            assetId: assetId,
            amount: 2
        }]
    }
	
colu.burnAsset(args, function (err, body) {
if (err) return console.error(err) console.log("Body: ", body) }) }) colu.init()

response

{ txHex: '0100000002346ab93dd39019102a78f64fb462922f8f2fc64f4de382998486ce7dca95428a000000001976a914a73e70ca6fdb743515508a47dd36e922527174b188acffffffffb3630450c091566c99f4807381647f1b440402d086394aa22480664484238b12000000001976a914a73e70ca6fdb743515508a47dd36e922527174b188acffffffff020000000000000000086a06434302251f0258020000000000001976a914a73e70ca6fdb743515508a47dd36e922527174b188ac00000000',
  multisigOutputs: [],
  coloredOutputIndexes: [],
  financeTxid: '128b238444668024a24a3986d00204441b7f64817380f4996c5691c0500463b3',
  txid: '4effebaa539b527a5a1990d8f232eb04fbc4e3966a9834926d451d902993b6cd' }

Get Asset Data

Try it with SDK explorer

getAssetData API Documentation

TITLERequest asset data and metadata

VERSION0.1.0

METHODcoloredCoins.getAssetData

Description

This SDK method is used to get the data of the issuance of an asset

Parameters
FieldTypeDescription
params

JSON

    assetId

String

Asset ID

    addresses(optional)

String[]

Addresses from where to get the assetId data (default value is null)

    numConfirmations(optional)

Number

numConfirmations Number of confirmation on the blockchain (default value is 0)

callback

Object

callback function

Success
FieldTypeDescription
assetId

String

Asset ID

assetAmount

Number

Amount of assets

assetTotalAmount

Number

Total amount of assets ever issued

assetData

JSON[]

Asset data object array

    address

String

Asset Address

    amount

Number

Asset amount

    utxo

String

Asset UTXO

    metadata

JSON

Asset data object

        divisibility

Number

How divisible is the asset

        version

String

Version of protocol as string

        totalSupply

Number

Total amount of the asset that was issued

        numOfHolders

Number

Number of addresses that have any amount of the asset

        numOfTransactions

Number

Number of transactions that the asset was passed in

        numOfIssuance

Number

Number of times an amount of the asset was issued

        firstAppearsInBlock

Number

First time this asset appeared in the blockchain (first issue)

        metadataOfIssuance

Object

Metadata of the issuance

            assetId

String

Asset Id

            assetName

String

Asset Name

            assetGenesis

String

Genesis transaction where the asset was created (in case of re issue)

            issuer

String

Name of the issuer

            description

String

Description of the asset

            urls

Object[]

Array of URL type objects

                name

String

Name of the url

                url

String

The url

                mimeType

String

Mime type of the data in the url

                dataHash

String

If needed hash of the data that in the url (for proof reasons)

            userData

JSON

Any arbitrary json data that issuer has entered

        rulesOfIssuance

Object

Object for the rules of the issuance

            version

Number

Version of the rule system

            fees

Object

                items

Object[]

Array of fee type items

                    address

String

Address to send the fee

                    assetId

String

Asset id to send fee (btc if none asset)

                    value

Number

Value to send for the fee (in satoshi or amount)

                locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

            expiration

Object

Expiration object used to loan an asset, when asset expires it moves back to last output

                validUntil

Number

When the asset is consider expired

                locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

            minters

Object[]

Array of minter objects, (addresses that can issue the asset)

                address

String

Address of the minter

                locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type (if the minter can add minters)

            holders

Object[]

Array of holder type objects, they specify in what addresses the asset is considered valid

                address

String

Address where the asset is considered valid

                locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

        metadatOfUtxo

Object

Metadata of the specific utxo from the transaction

            assetId

String

Asset Id

            assetName

String

Asset Name

            assetGenesis

String

Genesis transaction where the asset was created (in case of re issue)

            issuer

String

Name of the issuer

            description

String

description of the asset

            urls

Object[]

Array of URL type objects

                name

String

Name of the url

                url

String

The url

                mimeType

String

Mime type of the data in the url

                dataHash

String

If needed hash of the data that in the url (for proof reasons)

            userData

JSON

Any arbitrary json data that the pervious owner of the output has entered

        rulesofUtxo

Object

Object for the rules of the asset

            version

Number

Version of the rule system

            fees

Object

                items

Object[]

Array of fee type items

                    address

String

Address to send the fee

                    assetId

String

Asset id to send fee (btc if none asset)

                    value

Number

Value to send for the fee (in satoshi or amount)

                locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

            expiration

Object

Expiration object used to loan an asset, when asset expires it moves back to last output

                validUntil

Number

When the asset is consider expired

                locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

            minters

Object[]

Array of minter objects, (addresses that can issue the asset)

                address

String

Address of the minter

                locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type (if the minter can add minters)

            holders

Object[]

Array of holder type objects, they specify in what addresses the asset is considered valid

                address

String

Address where the asset is considered valid

                locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

Get Asset Data


var Colu = require('colu')

var privateSeed = '1af0d2500cee79344a84bcf374c04b85835390d8a3e8565e594d307a28efb656'
var assetId = 'LFJMdgGYpNkwos7L7YjLPAEG1v57Ujvq3enfm'
var addresses = ['mzKewG4Vo9HFqWRjcGpUVgaA1GrH1raP7q','mkvqtc25vKXp7Xf5SqqHVZYU5BAgwTas8B']

var settings = {
    network: 'testnet',
    privateSeed: privateSeed
}

var args= {
    assetId: assetId,
    addresses: addresses,
    numConfirmations: 0
}

var colu = new Colu(settings)
colu.on('connect', function () {
colu.coloredCoins.getAssetData(args, function (err, body) {
if (err) return console.error(err) console.log("assetData: ", JSON.stringify(body)) }) }) colu.init()

response

{
    "assetId":"LFJMdgGYpNkwos7L7YjLPAEG1v57Ujvq3enfm",
    "assetAmount":7,
    "assetTotalAmount":43,
    "assetData":[{
        "address":"mkvqtc25vKXp7Xf5SqqHVZYU5BAgwTas8B",
        "amount":2,
        "utxo":"a1529a9a5e3705fb385f814af5cef6a20a73db63828b81aea436be7ef8325c55:0",
        "metadata":{
            "assetId":"LFJMdgGYpNkwos7L7YjLPAEG1v57Ujvq3enfm",
            "divisibility":0,
            "lockStatus":null,
            "someUtxo":"0869657b4882564c5178bf03e9c28d120ef364cd00afb957186ee0baaa4d9c51:0",
            "totalSupply":43,
            "numOfHolders":10,
            "numOfTransfers":9,
            "numOfIssuance":1,
            "firstBlock":487864,
            "issuanceTxid":"6b89efcddc8ed97d5a511615688c44226dabbee9c604b1f6e26c4e93ace4d55e",
            "metadataOfIssuence":{
                "data":{
                    "assetName":"name",
                    "issuer":"tst_t65",
                    "description":"fsddf",
                    "urls":[{
                        "name":"icon",
                        "url":"https://s3-us-west-2.amazonaws.com/colu-website/O52VeRdjN8qE3-kj-lh1EUNo.png",
                        "dataHash":"a6ffa485bf1549ed2c6f53432c4b4bf5c7f241f2c95929a2f0650e5c5213667d",
                        "mimeType":"image/png"
                    }],
                    "userData":{
                        "meta":[{
                            "key":"ddd",
                            "value":"fff",
                            "type":"String"
                        }]
                    }
                }
            },
            "sha2Issue":"03b0ef51521c79f2ee173c28899d1e28cc028cd59220d5537365079d8428845bcf"
        }
    },{
        "address":"mzKewG4Vo9HFqWRjcGpUVgaA1GrH1raP7q",
        "amount":5,
        "utxo":"0869657b4882564c5178bf03e9c28d120ef364cd00afb957186ee0baaa4d9c51:0",
        "metadata":{
            "assetId":"LFJMdgGYpNkwos7L7YjLPAEG1v57Ujvq3enfm",
            "divisibility":0,
            "lockStatus":null,
            "someUtxo":"0869657b4882564c5178bf03e9c28d120ef364cd00afb957186ee0baaa4d9c51:0",
            "totalSupply":43,
            "numOfHolders":10,
            "numOfTransfers":9,
            "numOfIssuance":1,
            "firstBlock":487864,
            "issuanceTxid":"6b89efcddc8ed97d5a511615688c44226dabbee9c604b1f6e26c4e93ace4d55e",
            "metadataOfIssuence":{
                "data":{
                    "assetName":"name",
                    "issuer":"tst_t65",
                    "description":"fsddf",
                    "urls":[{
                        "name":"icon",
                        "url":"https://s3-us-west-2.amazonaws.com/colu-website/O52VeRdjN8qE3-kj-lh1EUNo.png",
                        "dataHash":"a6ffa485bf1549ed2c6f53432c4b4bf5c7f241f2c95929a2f0650e5c5213667d",
                        "mimeType":"image/png"
                    }],
                    "userData":{
                        "meta":[{
                            "key":"ddd",
                            "value":"fff",
                            "type":"String"
                        }]
                    }
                }
            },
            "sha2Issue":"03b0ef51521c79f2ee173c28899d1e28cc028cd59220d5537365079d8428845bcf"
        }
    }]
}

Get Asset Data


var Colu = require('colu')

var privateSeed = '1af0d2500cee79344a84bcf374c04b85835390d8a3e8565e594d307a28efb656'
var assetId = 'LFJMdgGYpNkwos7L7YjLPAEG1v57Ujvq3enfm'
var addresses = ['mzKewG4Vo9HFqWRjcGpUVgaA1GrH1raP7q','mkvqtc25vKXp7Xf5SqqHVZYU5BAgwTas8B']

var settings = {
    network: 'testnet',
    privateSeed: privateSeed
}

var args= {
    assetId: assetId,
    addresses: addresses,
    numConfirmations: 0
}

var colu = new Colu(settings)
colu.on('connect', function () {
colu.coloredCoins.getAssetData(args, function (err, body) {
if (err) return console.error(err) console.log("assetData: ", JSON.stringify(body)) }) }) colu.init()

response

{
    "assetId":"LFJMdgGYpNkwos7L7YjLPAEG1v57Ujvq3enfm",
    "assetAmount":7,
    "assetTotalAmount":43,
    "assetData":[{
        "address":"mkvqtc25vKXp7Xf5SqqHVZYU5BAgwTas8B",
        "amount":2,
        "utxo":"a1529a9a5e3705fb385f814af5cef6a20a73db63828b81aea436be7ef8325c55:0",
        "metadata":{
            "assetId":"LFJMdgGYpNkwos7L7YjLPAEG1v57Ujvq3enfm",
            "divisibility":0,
            "lockStatus":null,
            "someUtxo":"0869657b4882564c5178bf03e9c28d120ef364cd00afb957186ee0baaa4d9c51:0",
            "totalSupply":43,
            "numOfHolders":10,
            "numOfTransfers":9,
            "numOfIssuance":1,
            "firstBlock":487864,
            "issuanceTxid":"6b89efcddc8ed97d5a511615688c44226dabbee9c604b1f6e26c4e93ace4d55e",
            "metadataOfIssuence":{
                "data":{
                    "assetName":"name",
                    "issuer":"tst_t65",
                    "description":"fsddf",
                    "urls":[{
                        "name":"icon",
                        "url":"https://s3-us-west-2.amazonaws.com/colu-website/O52VeRdjN8qE3-kj-lh1EUNo.png",
                        "dataHash":"a6ffa485bf1549ed2c6f53432c4b4bf5c7f241f2c95929a2f0650e5c5213667d",
                        "mimeType":"image/png"
                    }],
                    "userData":{
                        "meta":[{
                            "key":"ddd",
                            "value":"fff",
                            "type":"String"
                        }]
                    }
                }
            },
            "sha2Issue":"03b0ef51521c79f2ee173c28899d1e28cc028cd59220d5537365079d8428845bcf"
        }
    },{
        "address":"mzKewG4Vo9HFqWRjcGpUVgaA1GrH1raP7q",
        "amount":5,
        "utxo":"0869657b4882564c5178bf03e9c28d120ef364cd00afb957186ee0baaa4d9c51:0",
        "metadata":{
            "assetId":"LFJMdgGYpNkwos7L7YjLPAEG1v57Ujvq3enfm",
            "divisibility":0,
            "lockStatus":null,
            "someUtxo":"0869657b4882564c5178bf03e9c28d120ef364cd00afb957186ee0baaa4d9c51:0",
            "totalSupply":43,
            "numOfHolders":10,
            "numOfTransfers":9,
            "numOfIssuance":1,
            "firstBlock":487864,
            "issuanceTxid":"6b89efcddc8ed97d5a511615688c44226dabbee9c604b1f6e26c4e93ace4d55e",
            "metadataOfIssuence":{
                "data":{
                    "assetName":"name",
                    "issuer":"tst_t65",
                    "description":"fsddf",
                    "urls":[{
                        "name":"icon",
                        "url":"https://s3-us-west-2.amazonaws.com/colu-website/O52VeRdjN8qE3-kj-lh1EUNo.png",
                        "dataHash":"a6ffa485bf1549ed2c6f53432c4b4bf5c7f241f2c95929a2f0650e5c5213667d",
                        "mimeType":"image/png"
                    }],
                    "userData":{
                        "meta":[{
                            "key":"ddd",
                            "value":"fff",
                            "type":"String"
                        }]
                    }
                }
            },
            "sha2Issue":"03b0ef51521c79f2ee173c28899d1e28cc028cd59220d5537365079d8428845bcf"
        }
    }]
}

Get Asset Data


<html>
 <head>
   <script type="text/javascript" src="colu.client.js"></script>
 </head>
 <body>
   <script>
     var privateSeed = '1af0d2500cee79344a84bcf374c04b85835390d8a3e8565e594d307a28efb656'
     var assetId = 'LFJMdgGYpNkwos7L7YjLPAEG1v57Ujvq3enfm'
     var addresses = ['mzKewG4Vo9HFqWRjcGpUVgaA1GrH1raP7q','mkvqtc25vKXp7Xf5SqqHVZYU5BAgwTas8B']

     var settings = {
       network: 'testnet',
       privateSeed: privateSeed
     }

     var args= {
       assetId: assetId,
       addresses: addresses,
       numConfirmations: 0
     }

     var colu = new Colu(settings)
     colu.on('connect', function () {
colu.coloredCoins.getAssetData(args, function (err, body) {
if (err) return console.error(err) console.log("assetData: ", JSON.stringify(body)) }) }) colu.init() </script> </body> </html>

response

{
    "assetId":"LFJMdgGYpNkwos7L7YjLPAEG1v57Ujvq3enfm",
    "assetAmount":7,
    "assetTotalAmount":43,
    "assetData":[{
        "address":"mkvqtc25vKXp7Xf5SqqHVZYU5BAgwTas8B",
        "amount":2,
        "utxo":"a1529a9a5e3705fb385f814af5cef6a20a73db63828b81aea436be7ef8325c55:0",
        "metadata":{
            "assetId":"LFJMdgGYpNkwos7L7YjLPAEG1v57Ujvq3enfm",
            "divisibility":0,
            "lockStatus":null,
            "someUtxo":"0869657b4882564c5178bf03e9c28d120ef364cd00afb957186ee0baaa4d9c51:0",
            "totalSupply":43,
            "numOfHolders":10,
            "numOfTransfers":9,
            "numOfIssuance":1,
            "firstBlock":487864,
            "issuanceTxid":"6b89efcddc8ed97d5a511615688c44226dabbee9c604b1f6e26c4e93ace4d55e",
            "metadataOfIssuence":{
                "data":{
                    "assetName":"name",
                    "issuer":"tst_t65",
                    "description":"fsddf",
                    "urls":[{
                        "name":"icon",
                        "url":"https://s3-us-west-2.amazonaws.com/colu-website/O52VeRdjN8qE3-kj-lh1EUNo.png",
                        "dataHash":"a6ffa485bf1549ed2c6f53432c4b4bf5c7f241f2c95929a2f0650e5c5213667d",
                        "mimeType":"image/png"
                    }],
                    "userData":{
                        "meta":[{
                            "key":"ddd",
                            "value":"fff",
                            "type":"String"
                        }]
                    }
                }
            },
            "sha2Issue":"03b0ef51521c79f2ee173c28899d1e28cc028cd59220d5537365079d8428845bcf"
        }
    },{
        "address":"mzKewG4Vo9HFqWRjcGpUVgaA1GrH1raP7q",
        "amount":5,
        "utxo":"0869657b4882564c5178bf03e9c28d120ef364cd00afb957186ee0baaa4d9c51:0",
        "metadata":{
            "assetId":"LFJMdgGYpNkwos7L7YjLPAEG1v57Ujvq3enfm",
            "divisibility":0,
            "lockStatus":null,
            "someUtxo":"0869657b4882564c5178bf03e9c28d120ef364cd00afb957186ee0baaa4d9c51:0",
            "totalSupply":43,
            "numOfHolders":10,
            "numOfTransfers":9,
            "numOfIssuance":1,
            "firstBlock":487864,
            "issuanceTxid":"6b89efcddc8ed97d5a511615688c44226dabbee9c604b1f6e26c4e93ace4d55e",
            "metadataOfIssuence":{
                "data":{
                    "assetName":"name",
                    "issuer":"tst_t65",
                    "description":"fsddf",
                    "urls":[{
                        "name":"icon",
                        "url":"https://s3-us-west-2.amazonaws.com/colu-website/O52VeRdjN8qE3-kj-lh1EUNo.png",
                        "dataHash":"a6ffa485bf1549ed2c6f53432c4b4bf5c7f241f2c95929a2f0650e5c5213667d",
                        "mimeType":"image/png"
                    }],
                    "userData":{
                        "meta":[{
                            "key":"ddd",
                            "value":"fff",
                            "type":"String"
                        }]
                    }
                }
            },
            "sha2Issue":"03b0ef51521c79f2ee173c28899d1e28cc028cd59220d5537365079d8428845bcf"
        }
    }]
}

Get Asset Data


var Colu = require('colu')

var privateSeed = '1af0d2500cee79344a84bcf374c04b85835390d8a3e8565e594d307a28efb656'
var assetId = 'LFJMdgGYpNkwos7L7YjLPAEG1v57Ujvq3enfm'
var addresses = ['mzKewG4Vo9HFqWRjcGpUVgaA1GrH1raP7q','mkvqtc25vKXp7Xf5SqqHVZYU5BAgwTas8B']

var settings = {
    network: 'testnet',
    privateSeed: privateSeed
}

var args= {
    assetId: assetId,
    addresses: addresses,
    numConfirmations: 0
}

var colu = new Colu(settings)
colu.on('connect', function () {
colu.coloredCoins.getAssetData(args, function (err, body) {
if (err) return console.error(err) console.log("assetData: ", JSON.stringify(body)) }) }) colu.init()

response

{
    "assetId":"LFJMdgGYpNkwos7L7YjLPAEG1v57Ujvq3enfm",
    "assetAmount":7,
    "assetTotalAmount":43,
    "assetData":[{
        "address":"mkvqtc25vKXp7Xf5SqqHVZYU5BAgwTas8B",
        "amount":2,
        "utxo":"a1529a9a5e3705fb385f814af5cef6a20a73db63828b81aea436be7ef8325c55:0",
        "metadata":{
            "assetId":"LFJMdgGYpNkwos7L7YjLPAEG1v57Ujvq3enfm",
            "divisibility":0,
            "lockStatus":null,
            "someUtxo":"0869657b4882564c5178bf03e9c28d120ef364cd00afb957186ee0baaa4d9c51:0",
            "totalSupply":43,
            "numOfHolders":10,
            "numOfTransfers":9,
            "numOfIssuance":1,
            "firstBlock":487864,
            "issuanceTxid":"6b89efcddc8ed97d5a511615688c44226dabbee9c604b1f6e26c4e93ace4d55e",
            "metadataOfIssuence":{
                "data":{
                    "assetName":"name",
                    "issuer":"tst_t65",
                    "description":"fsddf",
                    "urls":[{
                        "name":"icon",
                        "url":"https://s3-us-west-2.amazonaws.com/colu-website/O52VeRdjN8qE3-kj-lh1EUNo.png",
                        "dataHash":"a6ffa485bf1549ed2c6f53432c4b4bf5c7f241f2c95929a2f0650e5c5213667d",
                        "mimeType":"image/png"
                    }],
                    "userData":{
                        "meta":[{
                            "key":"ddd",
                            "value":"fff",
                            "type":"String"
                        }]
                    }
                }
            },
            "sha2Issue":"03b0ef51521c79f2ee173c28899d1e28cc028cd59220d5537365079d8428845bcf"
        }
    },{
        "address":"mzKewG4Vo9HFqWRjcGpUVgaA1GrH1raP7q",
        "amount":5,
        "utxo":"0869657b4882564c5178bf03e9c28d120ef364cd00afb957186ee0baaa4d9c51:0",
        "metadata":{
            "assetId":"LFJMdgGYpNkwos7L7YjLPAEG1v57Ujvq3enfm",
            "divisibility":0,
            "lockStatus":null,
            "someUtxo":"0869657b4882564c5178bf03e9c28d120ef364cd00afb957186ee0baaa4d9c51:0",
            "totalSupply":43,
            "numOfHolders":10,
            "numOfTransfers":9,
            "numOfIssuance":1,
            "firstBlock":487864,
            "issuanceTxid":"6b89efcddc8ed97d5a511615688c44226dabbee9c604b1f6e26c4e93ace4d55e",
            "metadataOfIssuence":{
                "data":{
                    "assetName":"name",
                    "issuer":"tst_t65",
                    "description":"fsddf",
                    "urls":[{
                        "name":"icon",
                        "url":"https://s3-us-west-2.amazonaws.com/colu-website/O52VeRdjN8qE3-kj-lh1EUNo.png",
                        "dataHash":"a6ffa485bf1549ed2c6f53432c4b4bf5c7f241f2c95929a2f0650e5c5213667d",
                        "mimeType":"image/png"
                    }],
                    "userData":{
                        "meta":[{
                            "key":"ddd",
                            "value":"fff",
                            "type":"String"
                        }]
                    }
                }
            },
            "sha2Issue":"03b0ef51521c79f2ee173c28899d1e28cc028cd59220d5537365079d8428845bcf"
        }
    }]
}

Get Address Info

Try it with SDK explorer

getAddressInfo API Documentation

TITLERequest to get asset information for the address

VERSION0.1.0

METHODcoloredCoins.getAddressInfo

Description

This SDK method is used to get all the assets for the address, this information is per utxo owned by the address, also retrives uncolored utxos

Parameters
FieldTypeDescription
address

String

Base58 address

callback

Object

callback function

Success
FieldTypeDescription
address

String

Base58 address

utxos

Object[]

Arry of ccUtxo items

    scriptPubKey

Object

ScriptPubKey type object

        asm

String

Asm for the output

        hex

String

Hex for the output

        type

String

Bitcoin transaction type

        reqSigs

Number

Number of required signatures to redeem

        addresses

String[]

Addresses that can redeem

assets

Object[]

Array of assetInfo type objects

    amount

Number

Amount of the asset in the utxo

    assetId

String

Asset id

    issueTxid

String

Txid that links this utxo to is genises issuance

    divisibility

Number

How divisible the asset is

    lockStatus

Boolean

Was the issuance locked

Get Address Info

var Colu = require('colu')

var privateSeed = '1af0d2500cee79344a84bcf374c04b85835390d8a3e8565e594d307a28efb656'
var address = 'n3TjZPvivsP5xHgRS5zbs83vcYcqDzC8J4'

var settings = {
    network: 'testnet',
    privateSeed: privateSeed
}

var colu = new Colu(settings)
colu.on('connect', function () {
colu.coloredCoins.getAddressInfo(address, function (err, body) {
if (err) return console.error(err) console.log("Body: ", body) }) }) colu.init()

response

{
	"address":"n3TjZPvivsP5xHgRS5zbs83vcYcqDzC8J4",
	"utxos":[{
		"_id":"55c9c54be8000c05f40b1f77",
		"txid":"8b3cc0067c4e79294e2204198a011e88ecb0b5b1717abe1a96fb07559692d7cd",
		"index":3,
		"value":716,
		"blockheight":529600,
		"blocktime":"2015-08-11T11:31:37.000Z",
		"used":false,
		"assets":[],
		"scriptPubKey":{
			"asm":"OP_DUP OP_HASH160 f0b6e3687e74772d9fc09b2edb97126b1696f369 OP_EQUALVERIFY OP_CHECKSIG",
			"hex":"76a914f0b6e3687e74772d9fc09b2edb97126b1696f36988ac",
			"reqSigs":1,
			"type":"pubkeyhash",
			"addresses":["n3TjZPvivsP5xHgRS5zbs83vcYcqDzC8J4"]
		}
	},{
		"_id":"55c9c629e8000c05f40b208f",
		"txid":"d732eae09c6a6b2fa9094e32f95343297ed3136526dd72e7664f60657f6b094a",
		"index":3,
		"value":1316,
		"blockheight":529600,
		"blocktime":"2015-08-11T11:31:37.000Z",
		"used":false,
		"assets":[{
			"assetId":"LJ2kQLhyPhcJg2faZ1c6bXLzcCVBi27xUZZme",
			"amount":8,
			"issueTxid":"8b3cc0067c4e79294e2204198a011e88ecb0b5b1717abe1a96fb07559692d7cd",
			"divisibility":0
		}],
		"scriptPubKey":{
			"asm":"OP_DUP OP_HASH160 f0b6e3687e74772d9fc09b2edb97126b1696f369 OP_EQUALVERIFY OP_CHECKSIG",
			"hex":"76a914f0b6e3687e74772d9fc09b2edb97126b1696f36988ac",
			"reqSigs":1,
			"type":"pubkeyhash",
			"addresses":["n3TjZPvivsP5xHgRS5zbs83vcYcqDzC8J4"]
		}
	}]
}

Get Address Info

var Colu = require('colu')

var privateSeed = '1af0d2500cee79344a84bcf374c04b85835390d8a3e8565e594d307a28efb656'
var address = 'n3TjZPvivsP5xHgRS5zbs83vcYcqDzC8J4'

var settings = {
    network: 'testnet',
    privateSeed: privateSeed
}

var colu = new Colu(settings)
colu.on('connect', function () {
colu.coloredCoins.getAddressInfo(address, function (err, body) {
if (err) return console.error(err) console.log("Body: ", body) }) }) colu.init()

response

{
	"address":"n3TjZPvivsP5xHgRS5zbs83vcYcqDzC8J4",
	"utxos":[{
		"_id":"55c9c54be8000c05f40b1f77",
		"txid":"8b3cc0067c4e79294e2204198a011e88ecb0b5b1717abe1a96fb07559692d7cd",
		"index":3,
		"value":716,
		"blockheight":529600,
		"blocktime":"2015-08-11T11:31:37.000Z",
		"used":false,
		"assets":[],
		"scriptPubKey":{
			"asm":"OP_DUP OP_HASH160 f0b6e3687e74772d9fc09b2edb97126b1696f369 OP_EQUALVERIFY OP_CHECKSIG",
			"hex":"76a914f0b6e3687e74772d9fc09b2edb97126b1696f36988ac",
			"reqSigs":1,
			"type":"pubkeyhash",
			"addresses":["n3TjZPvivsP5xHgRS5zbs83vcYcqDzC8J4"]
		}
	},{
		"_id":"55c9c629e8000c05f40b208f",
		"txid":"d732eae09c6a6b2fa9094e32f95343297ed3136526dd72e7664f60657f6b094a",
		"index":3,
		"value":1316,
		"blockheight":529600,
		"blocktime":"2015-08-11T11:31:37.000Z",
		"used":false,
		"assets":[{
			"assetId":"LJ2kQLhyPhcJg2faZ1c6bXLzcCVBi27xUZZme",
			"amount":8,
			"issueTxid":"8b3cc0067c4e79294e2204198a011e88ecb0b5b1717abe1a96fb07559692d7cd",
			"divisibility":0
		}],
		"scriptPubKey":{
			"asm":"OP_DUP OP_HASH160 f0b6e3687e74772d9fc09b2edb97126b1696f369 OP_EQUALVERIFY OP_CHECKSIG",
			"hex":"76a914f0b6e3687e74772d9fc09b2edb97126b1696f36988ac",
			"reqSigs":1,
			"type":"pubkeyhash",
			"addresses":["n3TjZPvivsP5xHgRS5zbs83vcYcqDzC8J4"]
		}
	}]
}

Get Address Info


<html>
 <head>
   <script type="text/javascript" src="colu.client.js"></script>
 </head>
 <body>
   <script>
     var privateSeed = '1af0d2500cee79344a84bcf374c04b85835390d8a3e8565e594d307a28efb656'
     var address = 'n3TjZPvivsP5xHgRS5zbs83vcYcqDzC8J4'

     var settings = {
       network: 'testnet',
       privateSeed: privateSeed
     }

     var colu = new Colu(settings)
     colu.on('connect', function () {
colu.coloredCoins.getAddressInfo(address, function (err, body) {
if (err) return console.error(err) console.log("Body: ", body) }) }) colu.init() </script> </body> </html>

response

{
	"address":"n3TjZPvivsP5xHgRS5zbs83vcYcqDzC8J4",
	"utxos":[{
		"_id":"55c9c54be8000c05f40b1f77",
		"txid":"8b3cc0067c4e79294e2204198a011e88ecb0b5b1717abe1a96fb07559692d7cd",
		"index":3,
		"value":716,
		"blockheight":529600,
		"blocktime":"2015-08-11T11:31:37.000Z",
		"used":false,
		"assets":[],
		"scriptPubKey":{
			"asm":"OP_DUP OP_HASH160 f0b6e3687e74772d9fc09b2edb97126b1696f369 OP_EQUALVERIFY OP_CHECKSIG",
			"hex":"76a914f0b6e3687e74772d9fc09b2edb97126b1696f36988ac",
			"reqSigs":1,
			"type":"pubkeyhash",
			"addresses":["n3TjZPvivsP5xHgRS5zbs83vcYcqDzC8J4"]
		}
	},{
		"_id":"55c9c629e8000c05f40b208f",
		"txid":"d732eae09c6a6b2fa9094e32f95343297ed3136526dd72e7664f60657f6b094a",
		"index":3,
		"value":1316,
		"blockheight":529600,
		"blocktime":"2015-08-11T11:31:37.000Z",
		"used":false,
		"assets":[{
			"assetId":"LJ2kQLhyPhcJg2faZ1c6bXLzcCVBi27xUZZme",
			"amount":8,
			"issueTxid":"8b3cc0067c4e79294e2204198a011e88ecb0b5b1717abe1a96fb07559692d7cd",
			"divisibility":0
		}],
		"scriptPubKey":{
			"asm":"OP_DUP OP_HASH160 f0b6e3687e74772d9fc09b2edb97126b1696f369 OP_EQUALVERIFY OP_CHECKSIG",
			"hex":"76a914f0b6e3687e74772d9fc09b2edb97126b1696f36988ac",
			"reqSigs":1,
			"type":"pubkeyhash",
			"addresses":["n3TjZPvivsP5xHgRS5zbs83vcYcqDzC8J4"]
		}
	}]
}

Get Address Info

var Colu = require('colu')

var privateSeed = '1af0d2500cee79344a84bcf374c04b85835390d8a3e8565e594d307a28efb656'
var address = 'n3TjZPvivsP5xHgRS5zbs83vcYcqDzC8J4'

var settings = {
    network: 'testnet',
    privateSeed: privateSeed
}

var colu = new Colu(settings)
colu.on('connect', function () {
colu.coloredCoins.getAddressInfo(address, function (err, body) {
if (err) return console.error(err) console.log("Body: ", body) }) }) colu.init()

response

{
	"address":"n3TjZPvivsP5xHgRS5zbs83vcYcqDzC8J4",
	"utxos":[{
		"_id":"55c9c54be8000c05f40b1f77",
		"txid":"8b3cc0067c4e79294e2204198a011e88ecb0b5b1717abe1a96fb07559692d7cd",
		"index":3,
		"value":716,
		"blockheight":529600,
		"blocktime":"2015-08-11T11:31:37.000Z",
		"used":false,
		"assets":[],
		"scriptPubKey":{
			"asm":"OP_DUP OP_HASH160 f0b6e3687e74772d9fc09b2edb97126b1696f369 OP_EQUALVERIFY OP_CHECKSIG",
			"hex":"76a914f0b6e3687e74772d9fc09b2edb97126b1696f36988ac",
			"reqSigs":1,
			"type":"pubkeyhash",
			"addresses":["n3TjZPvivsP5xHgRS5zbs83vcYcqDzC8J4"]
		}
	},{
		"_id":"55c9c629e8000c05f40b208f",
		"txid":"d732eae09c6a6b2fa9094e32f95343297ed3136526dd72e7664f60657f6b094a",
		"index":3,
		"value":1316,
		"blockheight":529600,
		"blocktime":"2015-08-11T11:31:37.000Z",
		"used":false,
		"assets":[{
			"assetId":"LJ2kQLhyPhcJg2faZ1c6bXLzcCVBi27xUZZme",
			"amount":8,
			"issueTxid":"8b3cc0067c4e79294e2204198a011e88ecb0b5b1717abe1a96fb07559692d7cd",
			"divisibility":0
		}],
		"scriptPubKey":{
			"asm":"OP_DUP OP_HASH160 f0b6e3687e74772d9fc09b2edb97126b1696f369 OP_EQUALVERIFY OP_CHECKSIG",
			"hex":"76a914f0b6e3687e74772d9fc09b2edb97126b1696f36988ac",
			"reqSigs":1,
			"type":"pubkeyhash",
			"addresses":["n3TjZPvivsP5xHgRS5zbs83vcYcqDzC8J4"]
		}
	}]
}

Get Asset Holders

Try it with SDK explorer

getStakeHolders API Documentation

TITLERequest asset holders

VERSION0.1.0

METHODcoloredCoins.getStakeHolders

Description

This SDK method is used to get all the addresses that contain any value of the specified asset

Parameters
FieldTypeDescription
assetId

String

Asset unique ID

numConfirmations

Number

Number of confiramtions for the utxos to return

callback

Object

callback function

Success
FieldTypeDescription
holders

Object[]

Array of holder objects.

    address

Object[]

Address that has holding of the asset

    amount

Object[]

Amount of the asset in the address

Get Asset Holders


var Colu = require('colu')

var privateSeed = '1af0d2500cee79344a84bcf374c04b85835390d8a3e8565e594d307a28efb656'
var assetId = 'LKPaEDCyELaMbxLnxJu6YogSyQU5T579YrXtj'
var address = 'mk9gANEvrfg2p21mVez3s7sL5GKCFvHjQ5'
var numConfirmations = 1

var settings = {
    network: 'testnet',
    privateSeed: privateSeed
}

var colu = new Colu(settings)
colu.on('connect', function () {
colu.coloredCoins.getStakeHolders(assetId, numConfirmations, function (err, body) {
if (err) return console.error(err) console.log("Body: ", body) }) }) colu.init()

response

{
    assetId: 'LKPaEDCyELaMbxLnxJu6YogSyQU5T579YrXtj',
    holders: [{ 
        address: 'mj5kxkcec992pDkxveqrgiYJUTUVMFbqys', 
        amount: 1 
    }],
    divisibility: 0,
    lockStatus: null,
    someUtxo: '0732e6af03fb0b348240e286fc46aaa626b9cdc24090f8b60f7579aaa30304c3:0'
}

Get Asset Holders


var Colu = require('colu')

var privateSeed = '1af0d2500cee79344a84bcf374c04b85835390d8a3e8565e594d307a28efb656'
var assetId = 'LKPaEDCyELaMbxLnxJu6YogSyQU5T579YrXtj'
var address = 'mk9gANEvrfg2p21mVez3s7sL5GKCFvHjQ5'
var numConfirmations = 1

var settings = {
    network: 'testnet',
    privateSeed: privateSeed
}

var colu = new Colu(settings)
colu.on('connect', function () {
colu.coloredCoins.getStakeHolders(assetId, numConfirmations, function (err, body) {
if (err) return console.error(err) console.log("Body: ", body) }) }) colu.init()

response

{
    assetId: 'LKPaEDCyELaMbxLnxJu6YogSyQU5T579YrXtj',
    holders: [{ 
        address: 'mj5kxkcec992pDkxveqrgiYJUTUVMFbqys', 
        amount: 1 
    }],
    divisibility: 0,
    lockStatus: null,
    someUtxo: '0732e6af03fb0b348240e286fc46aaa626b9cdc24090f8b60f7579aaa30304c3:0'
}

Get Asset Holders


<html>
 <head>
   <script type="text/javascript" src="colu.client.js"></script>
 </head>
 <body>
   <script>
     var privateSeed = '1af0d2500cee79344a84bcf374c04b85835390d8a3e8565e594d307a28efb656'
     var assetId = 'LKPaEDCyELaMbxLnxJu6YogSyQU5T579YrXtj'
     var address = 'mk9gANEvrfg2p21mVez3s7sL5GKCFvHjQ5'
     var numConfirmations = 1

     var settings = {
       network: 'testnet',
       privateSeed: privateSeed
     }

     var colu = new Colu(settings)
     colu.on('connect', function () {
colu.coloredCoins.getStakeHolders(assetId, numConfirmations, function (err, body) {
if (err) return console.error(err) console.log("Body: ", body) }) }) colu.init() </script> </body> </html>

response

{
    assetId: 'LKPaEDCyELaMbxLnxJu6YogSyQU5T579YrXtj',
    holders: [{ 
        address: 'mj5kxkcec992pDkxveqrgiYJUTUVMFbqys', 
        amount: 1 
    }],
    divisibility: 0,
    lockStatus: null,
    someUtxo: '0732e6af03fb0b348240e286fc46aaa626b9cdc24090f8b60f7579aaa30304c3:0'
}

Get Asset Holders


var Colu = require('colu')

var privateSeed = '1af0d2500cee79344a84bcf374c04b85835390d8a3e8565e594d307a28efb656'
var assetId = 'LKPaEDCyELaMbxLnxJu6YogSyQU5T579YrXtj'
var address = 'mk9gANEvrfg2p21mVez3s7sL5GKCFvHjQ5'
var numConfirmations = 1

var settings = {
    network: 'testnet',
    privateSeed: privateSeed
}

var colu = new Colu(settings)
colu.on('connect', function () {
colu.coloredCoins.getStakeHolders(assetId, numConfirmations, function (err, body) {
if (err) return console.error(err) console.log("Body: ", body) }) }) colu.init()

response

{
    assetId: 'LKPaEDCyELaMbxLnxJu6YogSyQU5T579YrXtj',
    holders: [{ 
        address: 'mj5kxkcec992pDkxveqrgiYJUTUVMFbqys', 
        amount: 1 
    }],
    divisibility: 0,
    lockStatus: null,
    someUtxo: '0732e6af03fb0b348240e286fc46aaa626b9cdc24090f8b60f7579aaa30304c3:0'
}

Get Asset Metadata

Try it with SDK explorer

getAssetMetadata API Documentation

TITLERequest asset metadata and utxo metadata

VERSION0.1.0

METHODcoloredCoins.getAssetMetadata

Description

This SDK method is used to get the metadata of the issuance of an asset, if a specific utxo is provided it will also get the metadata for that specific utxo which was set by the previous owner of that asset on the blockchain

Parameters
FieldTypeDescription
assetId

String

Asset unique ID.

utxo(optional)

String

Unspent in : format

callback

Object

callback function

Success
FieldTypeDescription
divisibility

Number

How divisible is the asset

version

String

Version of protocol as string

totalSupply

Number

Total amount of the asset that was issued

numOfHolders

Number

Number of addresses that have any amount of the asset

numOfTransactions

Number

Number of transactions that the asset was passed in

numOfIssuance

Number

Number of times an amount of the asset was issued

firstAppearsInBlock

Number

First time this asset appeared in the blockchain (first issue)

metadataOfIssuance

Object

Metadata of the issuance

    assetId

String

Asset Id

    assetName

String

Asset Name

    assetGenesis

String

Genesis transaction where the asset was created (in case of re issue)

    issuer

String

Name of the issuer

    description

String

Description of the asset

    urls

Object[]

Array of URL type objects

        name

String

Name of the url

        url

String

The url

        mimeType

String

Mime type of the data in the url

        dataHash

String

If needed hash of the data that in the url (for proof reasons)

    userData

JSON

Any arbitrary json data that issuer has entered

rulesOfIssuance

Object

Object for the rules of the issuance

    version

Number

Version of the rule system

    fees

Object

        items

Object[]

Array of fee type items

            address

String

Address to send the fee

            assetId

String

Asset id to send fee (btc if none asset)

            value

Number

Value to send for the fee (in satoshi or amount)

        locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

    expiration

Object

Expiration object used to loan an asset, when asset expires it moves back to last output

        validUntil

Number

When the asset is consider expired

        locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

    minters

Object[]

Array of minter objects, (addresses that can issue the asset)

        address

String

Address of the minter

        locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type (if the minter can add minters)

    holders

Object[]

Array of holder type objects, they specify in what addresses the asset is considered valid

        address

String

Address where the asset is considered valid

        locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

metadatOfUtxo

Object

Metadata of the specific utxo from the transaction

    assetId

String

Asset Id

    assetName

String

Asset Name

    assetGenesis

String

Genesis transaction where the asset was created (in case of re issue)

    issuer

String

Name of the issuer

    description

String

description of the asset

    urls

Object[]

Array of URL type objects

        name

String

Name of the url

        url

String

The url

        mimeType

String

Mime type of the data in the url

        dataHash

String

If needed hash of the data that in the url (for proof reasons)

    userData

JSON

Any arbitrary json data that the pervious owner of the output has entered

rulesofUtxo

Object

Object for the rules of the asset

    version

Number

Version of the rule system

    fees

Object

        items

Object[]

Array of fee type items

            address

String

Address to send the fee

            assetId

String

Asset id to send fee (btc if none asset)

            value

Number

Value to send for the fee (in satoshi or amount)

        locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

    expiration

Object

Expiration object used to loan an asset, when asset expires it moves back to last output

        validUntil

Number

When the asset is consider expired

        locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

    minters

Object[]

Array of minter objects, (addresses that can issue the asset)

        address

String

Address of the minter

        locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type (if the minter can add minters)

    holders

Object[]

Array of holder type objects, they specify in what addresses the asset is considered valid

        address

String

Address where the asset is considered valid

        locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

Get Asset Metadata

var Colu = require('colu')

var privateSeed = '1af0d2500cee79344a84bcf374c04b85835390d8a3e8565e594d307a28efb656'
var assetId = 'LFJMdgGYpNkwos7L7YjLPAEG1v57Ujvq3enfm'
var address = 'mzKewG4Vo9HFqWRjcGpUVgaA1GrH1raP7q'
var txid = '6b89efcddc8ed97d5a511615688c44226dabbee9c604b1f6e26c4e93ace4d55e'
var utxo = txid+':1'

var settings = {
    network: 'testnet',
    privateSeed: privateSeed
}

var colu = new Colu(settings)
colu.on('connect', function () {
colu.coloredCoins.getAssetMetadata(assetId, utxo, function (err, body) {
if (err) return console.error(err) console.log("Body: ", body) }) }) colu.init()

response

{
    assetId: 'LFJMdgGYpNkwos7L7YjLPAEG1v57Ujvq3enfm',
    divisibility: 0,
    lockStatus: null,
    someUtxo: '0869657b4882564c5178bf03e9c28d120ef364cd00afb957186ee0baaa4d9c51:0',
    totalSupply: 43,
    numOfHolders: 10,
    numOfTransfers: 9,
    numOfIssuance: 1,
    firstBlock: 487864,
    issuanceTxid: '6b89efcddc8ed97d5a511615688c44226dabbee9c604b1f6e26c4e93ace4d55e',
    metadataOfIssuence: { 
        data: { 
            assetName: 'name',
            issuer: 'tst_t65',
            description: 'fsddf',
            urls: [Object],
            userData: [Object] 
        } 
    },
    sha2Issue: '03b0ef51521c79f2ee173c28899d1e28cc028cd59220d5537365079d8428845bcf' 
}

Get Asset Metadata

var Colu = require('colu')

var privateSeed = '1af0d2500cee79344a84bcf374c04b85835390d8a3e8565e594d307a28efb656'
var assetId = 'LFJMdgGYpNkwos7L7YjLPAEG1v57Ujvq3enfm'
var address = 'mzKewG4Vo9HFqWRjcGpUVgaA1GrH1raP7q'
var txid = '6b89efcddc8ed97d5a511615688c44226dabbee9c604b1f6e26c4e93ace4d55e'
var utxo = txid+':1'

var settings = {
    network: 'testnet',
    privateSeed: privateSeed
}

var colu = new Colu(settings)
colu.on('connect', function () {
colu.coloredCoins.getAssetMetadata(assetId, utxo, function (err, body) {
if (err) return console.error(err) console.log("Body: ", body) }) }) colu.init()

response

{
    assetId: 'LFJMdgGYpNkwos7L7YjLPAEG1v57Ujvq3enfm',
    divisibility: 0,
    lockStatus: null,
    someUtxo: '0869657b4882564c5178bf03e9c28d120ef364cd00afb957186ee0baaa4d9c51:0',
    totalSupply: 43,
    numOfHolders: 10,
    numOfTransfers: 9,
    numOfIssuance: 1,
    firstBlock: 487864,
    issuanceTxid: '6b89efcddc8ed97d5a511615688c44226dabbee9c604b1f6e26c4e93ace4d55e',
    metadataOfIssuence: { 
        data: { 
            assetName: 'name',
            issuer: 'tst_t65',
            description: 'fsddf',
            urls: [Object],
            userData: [Object] 
        } 
    },
    sha2Issue: '03b0ef51521c79f2ee173c28899d1e28cc028cd59220d5537365079d8428845bcf' 
}

Get Asset Metadata


<html>
 <head>
   <script type="text/javascript" src="colu.client.js"></script>
 </head>
 <body>
   <script>
     var privateSeed = '1af0d2500cee79344a84bcf374c04b85835390d8a3e8565e594d307a28efb656'
     var assetId = 'LFJMdgGYpNkwos7L7YjLPAEG1v57Ujvq3enfm'
     var address = 'mzKewG4Vo9HFqWRjcGpUVgaA1GrH1raP7q'
     var txid = '6b89efcddc8ed97d5a511615688c44226dabbee9c604b1f6e26c4e93ace4d55e'
     var utxo = txid+':1'

     var settings = {
       network: 'testnet',
       privateSeed: privateSeed
     }

     var colu = new Colu(settings)
     colu.on('connect', function () {
colu.coloredCoins.getAssetMetadata(assetId, utxo, function (err, body) {
if (err) return console.error(err) console.log("Body: ", body) }) }) colu.init() </script> </body> </html>

response

{
    assetId: 'LFJMdgGYpNkwos7L7YjLPAEG1v57Ujvq3enfm',
    divisibility: 0,
    lockStatus: null,
    someUtxo: '0869657b4882564c5178bf03e9c28d120ef364cd00afb957186ee0baaa4d9c51:0',
    totalSupply: 43,
    numOfHolders: 10,
    numOfTransfers: 9,
    numOfIssuance: 1,
    firstBlock: 487864,
    issuanceTxid: '6b89efcddc8ed97d5a511615688c44226dabbee9c604b1f6e26c4e93ace4d55e',
    metadataOfIssuence: { 
        data: { 
            assetName: 'name',
            issuer: 'tst_t65',
            description: 'fsddf',
            urls: [Object],
            userData: [Object] 
        } 
    },
    sha2Issue: '03b0ef51521c79f2ee173c28899d1e28cc028cd59220d5537365079d8428845bcf' 
}

Get Asset Metadata

var Colu = require('colu')

var privateSeed = '1af0d2500cee79344a84bcf374c04b85835390d8a3e8565e594d307a28efb656'
var assetId = 'LFJMdgGYpNkwos7L7YjLPAEG1v57Ujvq3enfm'
var address = 'mzKewG4Vo9HFqWRjcGpUVgaA1GrH1raP7q'
var txid = '6b89efcddc8ed97d5a511615688c44226dabbee9c604b1f6e26c4e93ace4d55e'
var utxo = txid+':1'

var settings = {
    network: 'testnet',
    privateSeed: privateSeed
}

var colu = new Colu(settings)
colu.on('connect', function () {
colu.coloredCoins.getAssetMetadata(assetId, utxo, function (err, body) {
if (err) return console.error(err) console.log("Body: ", body) }) }) colu.init()

response

{
    assetId: 'LFJMdgGYpNkwos7L7YjLPAEG1v57Ujvq3enfm',
    divisibility: 0,
    lockStatus: null,
    someUtxo: '0869657b4882564c5178bf03e9c28d120ef364cd00afb957186ee0baaa4d9c51:0',
    totalSupply: 43,
    numOfHolders: 10,
    numOfTransfers: 9,
    numOfIssuance: 1,
    firstBlock: 487864,
    issuanceTxid: '6b89efcddc8ed97d5a511615688c44226dabbee9c604b1f6e26c4e93ace4d55e',
    metadataOfIssuence: { 
        data: { 
            assetName: 'name',
            issuer: 'tst_t65',
            description: 'fsddf',
            urls: [Object],
            userData: [Object] 
        } 
    },
    sha2Issue: '03b0ef51521c79f2ee173c28899d1e28cc028cd59220d5537365079d8428845bcf' 
}

Get Assets

getAssets API Documentation

TITLERequest to get all wallet assets

VERSION0.1.0

METHODgetAssets

Description

This SDK method is used to get all assets held by addresses associated with the user wallet

Parameters
FieldTypeDescription
callback

Object

callback function

Success
FieldTypeDescription
address

String

Base58 address

txid

String

Transaction id

index

Number

Transaction index of the utxo

assetId

String

Asset id

amount

Number

Asset amount

issueTxid

String

Issuance transaction id

divisibility

Number

Asset divisibility

lockStatus

Boolean

Lock status

aggregationPolicy

String

Aggregation policy (aggregatable or dispersed)

assetIndex

Number

Asset index in the utxo

Get Assets

var Colu = require('colu')

var privateSeed = '1af0d2500cee79344a84bcf374c04b85835390d8a3e8565e594d307a28efb656'

var settings = {
    network: 'testnet',
    privateSeed: privateSeed
}

var colu = new Colu(settings)
colu.on('connect', function () {
colu.getAssets(function (err, body) {
if (err) return console.error(err) console.log("Body: ", body) }) }) colu.init()

response

[{ 
    address: 'mwfCjZu13rQAVmqfu97RkE4n6Xwgr7jvEK',
    txid: 'afe6a1d84ee508c4d9c8f7f511fb5701a1f758aff3a883416b6d74e184f8cb3d',
    index: 0,
    assetId: 'Ua4U2xUmTKgbu3WSb67g5NLSWBHL7QWdQTNH2b',
    amount: 1,
    issueTxid: 'afe6a1d84ee508c4d9c8f7f511fb5701a1f758aff3a883416b6d74e184f8cb3d',
    divisibility: 0,
    lockStatus: false,
    aggregationPolicy: 'aggregatable',
    assetIndex: 0 
}]

Get Assets

var Colu = require('colu')

var privateSeed = '1af0d2500cee79344a84bcf374c04b85835390d8a3e8565e594d307a28efb656'

var settings = {
    network: 'testnet',
    privateSeed: privateSeed
}

var colu = new Colu(settings)
colu.on('connect', function () {
colu.getAssets(function (err, body) {
if (err) return console.error(err) console.log("Body: ", body) }) }) colu.init()

response

[{ 
    address: 'mwfCjZu13rQAVmqfu97RkE4n6Xwgr7jvEK',
    txid: 'afe6a1d84ee508c4d9c8f7f511fb5701a1f758aff3a883416b6d74e184f8cb3d',
    index: 0,
    assetId: 'Ua4U2xUmTKgbu3WSb67g5NLSWBHL7QWdQTNH2b',
    amount: 1,
    issueTxid: 'afe6a1d84ee508c4d9c8f7f511fb5701a1f758aff3a883416b6d74e184f8cb3d',
    divisibility: 0,
    lockStatus: false,
    aggregationPolicy: 'aggregatable',
    assetIndex: 0 
}]

Get Assets

var Colu = require('colu')

var privateSeed = '1af0d2500cee79344a84bcf374c04b85835390d8a3e8565e594d307a28efb656'

var settings = {
    network: 'testnet',
    privateSeed: privateSeed
}

var colu = new Colu(settings)
colu.on('connect', function () {
colu.getAssets(function (err, body) {
if (err) return console.error(err) console.log("Body: ", body) }) }) colu.init()

response

[{ 
    address: 'mwfCjZu13rQAVmqfu97RkE4n6Xwgr7jvEK',
    txid: 'afe6a1d84ee508c4d9c8f7f511fb5701a1f758aff3a883416b6d74e184f8cb3d',
    index: 0,
    assetId: 'Ua4U2xUmTKgbu3WSb67g5NLSWBHL7QWdQTNH2b',
    amount: 1,
    issueTxid: 'afe6a1d84ee508c4d9c8f7f511fb5701a1f758aff3a883416b6d74e184f8cb3d',
    divisibility: 0,
    lockStatus: false,
    aggregationPolicy: 'aggregatable',
    assetIndex: 0 
}]

Get Assets

var Colu = require('colu')

var privateSeed = '1af0d2500cee79344a84bcf374c04b85835390d8a3e8565e594d307a28efb656'

var settings = {
    network: 'testnet',
    privateSeed: privateSeed
}

var colu = new Colu(settings)
colu.on('connect', function () {
colu.getAssets(function (err, body) {
if (err) return console.error(err) console.log("Body: ", body) }) }) colu.init()

response

[{ 
    address: 'mwfCjZu13rQAVmqfu97RkE4n6Xwgr7jvEK',
    txid: 'afe6a1d84ee508c4d9c8f7f511fb5701a1f758aff3a883416b6d74e184f8cb3d',
    index: 0,
    assetId: 'Ua4U2xUmTKgbu3WSb67g5NLSWBHL7QWdQTNH2b',
    amount: 1,
    issueTxid: 'afe6a1d84ee508c4d9c8f7f511fb5701a1f758aff3a883416b6d74e184f8cb3d',
    divisibility: 0,
    lockStatus: false,
    aggregationPolicy: 'aggregatable',
    assetIndex: 0 
}]

Colu SDK - Getting Started

In this getting started guide we will walk you through the two core examples of the Colu SDK, issuing a new asset and transferring an existing asset.

The examples given in this guide are written in javascript using the popular libraries node js and bitcoinjs

All the code snippets used in this getting started guide can be found on github.

First, we will walk you through the necessary steps needed to setup your machine in order to follow the rest of the guide.

Setup

In this section we will walk you through installing the required software in order to be able to follow the rest of our getting started guide.

 

 

 

 

Installing Node JS

Colu's SDK is currently available only for node js (more languages coming soon).
For completeness, this section walks you through the installation process of node js on Linux (Ubuntu).

Start with downloading the package by launching a terminal window and typing:

> curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -

Install node js by typing

> sudo apt-get install -y nodejs

Verify your node js installation

Open a text editor and save the following in a file called example.js

var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Colu\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');

Now launch a terminal window and type

> node example.js

Launch a web browser and visit localhost:1337. You should see the text "Colu"

 

 

 

 

Installing colu SDK

Colu SDK can be installed using the node package manager.
Open the command prompt in your project directory and type

npm install --save colu@latest

 

 

 

 

Initialization

Colu's SDK functionality is available through the Colu class.

The Colu class interacts behind the scenes with:


  • The ColoredCoins API: Issuing and Sending transactions and receiving asset data from the Bitcoin network

  • The Colu Server: For financing transactions

  • A local Bitcoin Wallet: Generating addresses and keys and signing transactions

HD wallets and the Private Seed

The Bitcoin wallet is an HD wallet, which is highly suitable for businesses. HD wallets are deterministic in the sense that the entire (infinite) tree of available addresses and keys are derivable from a single number, or private seed. This private seed is a Master Key controlling all the funds in the wallet.

The Private Seed is the single piece of information you need to make sure to manage securely on your end when you use our SDK

Initializing the Colu Object

In order to initialize an instance of the Colu class we must provide the constructor with


  • The type of Bitcoin network (mainnet or testnet)

  • The API Key (only for mainnet)

  • A private seed (optional)

  • The URL of the relevant ColoredCoins API (optional)

  • The URL of the Colu Server (optional)

If you do not provide a private seed, a random one will be created automatically

Initializing the Colu Object on Testnet

Let's define the initialization settings for working on top of the Bitcoin 'testnet' network:

var settings = {
network: 'testnet',
privateSeed: null,
coloredCoinsHost: 'https://testnet.api.coloredcoins.org',
coluHost: 'https://testnet.engine.colu.co'
}

Initializing the Colu Object on Mainnet

When we define the initialization settings to work on top of the Bitcoin 'mainnet' network, we will define the 'network' to work on 'mainnet'.
We also need to define the apiKey property setting:

var apiKey = 'Your API Key'
var settings = {
network: 'mainnet',
apiKey: apiKey,
privateSeed: null
}

Now require the Colu library and initialize a colu object with the above settings:

var Colu = require('colu')
var colu = new Colu(settings)

The colu SDK supports two ways to interact with colu objects.

Event based initialization


In this case your code goes in the callback for the connect call. For example, we can log the private seed of the colu object:

colu.on('connect', function () {
privateSeed = colu.hdwallet.getPrivateSeed()
console.log("privateSeed: ",privateSeed)
});

To run the code, you need to call the init method

colu.init()

In this case we should see an output of this form:

> privateSeed:  abcd4986fdac1b3a710892ef6eaa708d619d67100d0514ab996582966f927982

This newly generated private seed initializes a new HD wallet, which we will use in the remainder of this guide.

Alternatively, we can do everything inside the constructor

Callback based initialization


In this case your code goes in the callback of the init method (which returns itself), in this case the above example will look like so:

colu.init(function (err, coluInstance) {
if (err) throw err
privateSeed = coluInstance.hdwallet.getPrivateSeed()
console.log("privateSeed: ",privateSeed)
})

and there is no need to call the init method as well.

In the rest of this getting started tutorial we will use the event based approach which we find a little more clear and flexible.

 

 

 

 

Issue an Asset

In this section we explain how to use Colu's SDK to issue a new Asset.

 

 

 

 

Simple Issue

We start by using the same private seed that we just created in the initialization section:

var Colu = require('colu')
var settings = {
network: 'testnet',
privateSeed: 'abcd4986fdac1b3a710892ef6eaa708d619d67100d0514ab996582966f927982'
}
var colu = new Colu(settings)

This time we ask the colu object to issue a new asset with 1 million units. This is done by specifying the number of units using the amount key in a json object:

var asset = {
amount: 1000000
}

Now we can issue this asset by invoking the issueAsset method on the colu object with our asset parameter:

colu.on('connect', function () {
colu.issueAsset(asset, function (err, body) {
if (err) return console.error(err)
console.log("Body: ",body)
})
})

colu.init()

Here is the response:

Body:  { txHex: '010000000181704ea8e573a0a7dbec6e0213d757721f82afc9f91e453b27d2e30c8c4f1ac10000000000ffffffff0358020000000000001976a9147aa6f36ef275974e795f58c207d21a280bbd3af688ac00000000000000000c6a0a4343010526440026441078050000000000001976a9147aa6f36ef275974e795f58c207d21a280bbd3af688ac00000000',
assetId: 'LGDBaMSAkgVJ5aoERUzyYcof6c4ypRArGmpZc',
multisigOutputs: [],
txid: '1ca23e71ca24e4ff16e13009c77c2f67051547a8df1e3e6fc5a9cdb56fcd04ed',
receivingAddresses:
[ { address: 'mrhUjQjcZZxMcmPnrCZZ3BqYHNyVeQXCea',
amount: 1000000 } ],
issueAddress: 'mrhUjQjcZZxMcmPnrCZZ3BqYHNyVeQXCea' }

The return message tells us that we successfully issued a new asset with id LGDBaMSAkgVJ5aoERUzyYcof6c4ypRArGmpZc in transaction 1ca23e71ca24e4ff16e13009c77c2f67051547a8df1e3e6fc5a9cdb56fcd04ed.
The Asset was issued at address mrhUjQjcZZxMcmPnrCZZ3BqYHNyVeQXCea (which is one of the addresses in our local HD wallet).

Let's confirm that using the colored coins testnet explorer.

First let's look at the asset

ASSET NAME: N/A                           LOCKED ASSET

ISSUANCE
Name Amount utxo
LGDBaMSAkgVJ5aoERUzyYcof6c4ypRArGmpZc 1000000 1ca23e71ca24e4ff16e13009c77c2f67051547a8df1e3e6fc5a9cdb56fcd04ed

HOLDERS
Address Amount
mrhUjQjcZZxMcmPnrCZZ3BqYHNyVeQXCea 1000000

TRANSFER TRANSACTIONS
No Transactions Found

ISSUE TRANSACTIONS
dba9acac2f0afa45aa5da9c37bc283...
Sent 0.00002 Asset Sent 1000000

The explorer confirms that there are 1,000,000 units of our LGDBaMSAkgVJ5aoERUzyYcof6c4ypRArGmpZc asset, all sitting in the issuance address mrhUjQjcZZxMcmPnrCZZ3BqYHNyVeQXCea.

Note that if you look at the issuance transaction you can see that 2000 satoshis were sent to the issuance address and another 1000 paid as transaction fee. Those costs are covered by Colu.

 

 

 

 

Issue with Metadata

Colored Coins assets can include arbitrary amounts of Metadata.

We can embed metadata in the asset at issuance by declaring a metadata key in the asset definition:

var Colu = require('colu')
var settings = {
network: 'testnet',
privateSeed: 'abcd4986fdac1b3a710892ef6eaa708d619d67100d0514ab996582966f927982'
}
var colu = new Colu(settings)

var asset = {
amount: 500,
metadata: {
'assetName': 'Mission Impossible 15',
'issuer': 'Fox Theater',
'description': 'Movie ticket to see the New Tom Cruise flick'
}
}

colu.on('connect', function () {
colu.issueAsset(asset, function (err, body) {
if (err) return console.error(err)
console.log("Body: ",body)
})
})

colu.init()

This example can be thought of as issuing 500 tickets to a movie.

Here is the response

Body:  { txHex: '0100000001f7782f48ce7bf39e349a97bcb06c48702b4e1dd68fbb9f0e786e8fae81e6c02f0000000000ffffffff04ac0200000000000047512103ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff21034976c163e25cfd8ff92c1962c2cbbb8fd60f3cf6a818e0bcac5fcb7e239ef33252ae58020000000000001976a914e57f8df8e3cae90571da07dc97ac781e1c6aa43288ac0000000000000000206a1e4343010261d5d531d0f6c9254f779ce530de02635e0930ac205201205210cc020000000000001976a914e57f8df8e3cae90571da07dc97ac781e1c6aa43288ac00000000',
assetId: 'LEUWnac9Pp7kZYC3W19xtVMVqL8jw6m19RZHu',
multisigOutputs: [],
txid: 'f9fff185dc1df89ffe13cd7e5668a0af2953622176de91232ec1be975c6114c4',
receivingAddresses: [ { address: 'n2SRqdXxbKpZPyVNBCdTM9Y5vHUcLEWVvE', amount: 500 } ],
issueAddress: 'n2SRqdXxbKpZPyVNBCdTM9Y5vHUcLEWVvE' }

Let's look at the asset

ASSET NAME: Mission Impossible 15         LOCKED ASSET

ISSUANCE
Name Issuer Amount utxo
Mission Impossible 15 Fox Theater 500 f9fff185dc1df89ffe13cd7e5668a0af2953622176de91232ec1be975c6114c4

HOLDERS
Address Amount
n2SRqdXxbKpZPyVNBCdTM9Y5vHUcLEWVvE 500

TRANSFER TRANSACTIONS
No Transactions Found

ISSUE TRANSACTIONS
f9fff185dc1df89ffe13cd7e5668a0...
Sent 0.00002 Asset Sent 500

This time we see the asset name and asset issuer. Please consult the colored coins protocol specification to learn about more general metadata structures that are supported. Later on we will learn how to use the SDK to query an asset and retrieve the full set of metadata.

 

 

 

 

Reissuing an Asset

In this section we will discuss asset re-issuance and it's relation to the concepts of Locked and Unlocked assets.

Note that for all the assets that we issued in the previous sections, the explorer displayed a LOCKED ASSET symbol near the asset name. Locked Assets are asset that are issued once and cannot be re-issued. There can be an unlimited number of locked assets in one Bitcoin address.

Unlocked assets on the other hand are tied to the issuance address in a way that we explore below.

Let's start by issuing an Unlocked asset. We do that by including the reissuable key in the asset definition and setting it to true:

var Colu = require('colu')
var settings = {
network: 'testnet',
privateSeed: 'abcd4986fdac1b3a710892ef6eaa708d619d67100d0514ab996582966f927982'
}
var colu = new Colu(settings)

var asset = {
amount: 1000000,
reissueable: true
}

colu.on('connect', function () {
colu.issueAsset(asset, function (err, body) {
if (err) return console.error(err)
console.log("Body: ",body)
})
})

colu.init()

Here is the response:

Body:  { txHex: '01000000017b58760bcdbe7c4701dc53f546ed1edc4ff6adf5b0ce35e162a56f8bba5aa2440000000000ffffffff0358020000000000001976a9145ed9f47408f7bc2567b8ef7da07c17e7e06f382c88ac00000000000000000c6a0a4343010526440026440078050000000000001976a9145ed9f47408f7bc2567b8ef7da07c17e7e06f382c88ac00000000',
assetId: 'U5haTxTknzcq94czuXQRHa7Nw38BUxnQWAX6w',
multisigOutputs: [],
txid: '72ea2228a6e555228a4e84685932eac1b395bfe512e81ce8bf9f27649be14dff',
receivingAddresses:
[ { address: 'mpAUurhbWXFtczKVPn7iLf7rfcDhMdH6tH',
amount: 1000000 } ],
issueAddress: 'mpAUurhbWXFtczKVPn7iLf7rfcDhMdH6tH' }

Let's look at this asset in the explorer:

ASSET NAME: N/A                          UNLOCKED ASSET

ISSUANCE
Name Issuer Amount utxo
U5haTxTknzcq94czuXQRHa... 1000000 72ea2228a6e555228a4e84685932eac1b395bfe512e81ce8bf9f27649be14dff

HOLDERS
Address Amount
mpAUurhbWXFtczKVPn7iLf7rfcDhMdH6tH 1000000

TRANSFER TRANSACTIONS
No Transactions Found
ISSUE TRANSACTIONS
72ea2228a6e555228a4e84685932ea...
Sent 0.00002 Asset Sent 1000000

Again we see that 1 million units were issued, only this time the asset is designated as UNLOCKED. What this means is that we can REISSUE it, i.e. make another issuance call and create more units.

When an unlocked asset is reissued we must specify the issuance address by adding an issueAddress key to the asset definition. So let's do that and reissue our U5haTxTknzcq94czuXQRHa7Nw38BUxnQWAX6w asset on the issuance address mpAUurhbWXFtczKVPn7iLf7rfcDhMdH6tH:

var Colu = require('colu')
var settings = {
network: 'testnet',
privateSeed: 'abcd4986fdac1b3a710892ef6eaa708d619d67100d0514ab996582966f927982'
}
var colu = new Colu(settings)

issueAddress = 'mpAUurhbWXFtczKVPn7iLf7rfcDhMdH6tH'

var asset = {
amount: 1000000,
reissueable: true,
issueAddress: issueAddress
}

colu.on('connect', function () {
colu.issueAsset(asset, function (err, body) {
if (err) return console.error(err)
console.log("Body: ",body)
})
})

colu.init()

And the response we get is:

Body:  { txHex: '0100000001a60a3017dd145682ba55e06fe8069cb10bbab0adf27d5493d36a9b04ea9719b70000000000ffffffff0358020000000000001976a9145ed9f47408f7bc2567b8ef7da07c17e7e06f382c88ac00000000000000000c6a0a4343010526440026440078050000000000001976a9145ed9f47408f7bc2567b8ef7da07c17e7e06f382c88ac00000000',
assetId: 'U5haTxTknzcq94czuXQRHa7Nw38BUxnQWAX6w',
multisigOutputs: [],
txid: 'a9918d8081a13ba6550f0dc8f52266b810447d05df8395ad59919a2bcc54ae56',
receivingAddresses:
[ { address: 'mpAUurhbWXFtczKVPn7iLf7rfcDhMdH6tH',
amount: 1000000 } ],
issueAddress: 'mpAUurhbWXFtczKVPn7iLf7rfcDhMdH6tH' }

So it looks like we succeeded in issuing the same assetID on the same address. Let's verify that with the explorer by looking at the asset:

ASSET NAME: N/A                          UNLOCKED ASSET
ISSUANCE
Name Issuer Amount utxo
U5haTxTknzcq94czuXQRHa... 1000000 72ea2228a6e555228a4e84685932eac1b395bfe512e81ce8bf9f27649be14dff
U5haTxTknzcq94czuXQRHa... 1000000 a9918d8081a13ba6550f0dc8f52266b810447d05df8395ad59919a2bcc54ae56

HOLDERS
Address Amount
mpAUurhbWXFtczKVPn7iLf7rfcDhMdH6tH 2000000

TRANSFER TRANSACTIONS
No Transactions Found
ISSUE TRANSACTIONS
72ea2228a6e555228a4e84685932ea...
Sent 0.00002 Asset Sent 1000000
a9918d8081a13ba6550f0dc8f52266...
Sent 0.00002 Asset Sent 1000000

Indeed, now there are 2 million units, both still sitting in the issuance address.

As an aside, let's try to issue an asset on an address to which we don't own the private key. An easy way to try that is to change one character in the wallet private seed. For example, below we changed the first letter a to b. The rest of the call is identical to what we did above:

var Colu = require('colu')
var settings = {
network: 'testnet',
privateSeed: 'abcd4986fdac1b3a710892ef6eaa708d619d67100d0514ab996582966f927982'
}
var colu = new Colu(settings)

issueAddress = 'mpAUurhbWXFtczKVPn7iLf7rfcDhMdH6tH'

var asset = {
amount: 1000000,
reissueable: true,
issueAddress: issueAddress
}

colu.on('connect', function () {
colu.issueAsset(asset, function (err, body) {
if (err) return console.error(err)
console.log("Body: ",body)
})
})

colu.init()

The response is

Addresss mpAUurhbWXFtczKVPn7iLf7rfcDhMdH6tH privateKey not found

which is to be expected, since obviously we shouldn't be able to issue an asset on an address that we don't control.

 

 

 

 

Issue and Send

One of the strengths of the new colored coins protocol is the ability to issue and send an asset within the same transaction.

Let's try to do that and issue 1 million units of an unlocked asset where upon issuance we send 250,000 units to another address. The destination address is added using the transfer key in the asset definition:

var Colu = require('colu')
var settings = {
network: 'testnet',
privateSeed: 'abcd4986fdac1b3a710892ef6eaa708d619d67100d0514ab996582966f927982'
}
var colu = new Colu(settings)

var asset = {
amount: 1000000,
reissueable: true,
transfer: [{
address: 'mvaHph557j63CyJxmEaJ8F38SC3cNetvaa', amount: 250000
}]
}

colu.on('connect', function () {
colu.issueAsset(asset, function (err, body) {
if (err) return console.error(err)
console.log("Body: ",body)
})
})

colu.init()

Here is the response

Body:  {
txHex: '0100000001239394eeeb02a16e49dd585d8c73223be28c524ac3e1b8463f3a8dd7ca240e750000000000ffffffff0358020000000000001976a914a52b6f9d2e1032c53e213b2e6d8710bf773f5d5d88ac00000000000000000c6a0a4343010526440021940078050000000000001976a914ab1bf706f8b437c269b3551e58b6279a117417d388ac00000000',
assetId: 'U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt',
txid: '2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453',
receivingAddresses: [{
amount: 250000,
address: 'mvaHph557j63CyJxmEaJ8F38SC3cNetvaa'
},{
amount: 750000,
address: 'mw7hLtuo9vnBNCs9PL7i2h7oqDfs4j8NJG'
}],
issueAddress: 'mw7hLtuo9vnBNCs9PL7i2h7oqDfs4j8NJG'
}

Let's look at the asset

HOLDERS
Address Amount
mvaHph557j63CyJxmEaJ8F38SC3cNetvaa 250000
mw7hLtuo9vnBNCs9PL7i2h7oqDfs4j8NJG 750000

TRANSFER TRANSACTIONS
No Transactions Found

ISSUE TRANSACTIONS
2cf2cbe850e9b6b1daf9b6cd190f1e...
Sent 0.00002 Asset Sent 1000000

This time we see that there are two holders to our asset, the new address mvaHph557j63CyJxmEaJ8F38SC3cNetvaa to which we sent 250,000 units and the issuance address mw7hLtuo9vnBNCs9PL7i2h7oqDfs4j8NJG which holds the remaining 750,000.

 

 

 

 

Asset Divisibility

All the assets we issued so far were issued with integral units. This makes sense for a large class of assets (e.g. representing a Movie Ticket). However, there are many use cases where an asset is naturally divisible. E.g. an asset that represents a currency.

We can issue divisible assets by adding a divisibility key to the asset definition. The value of that key defines the divisibility in terms of the number of places beyond the decimal point.

divisibility:0 corresponds to integers (1, 2, 3, etc...)
divisibility:1 corresponds to divisibility up to 1 decimal point (Numbers like 0.1, 0.9, 1.5, etc...)
divisibility:3 corresponds to divisibility up to 3 decimal points (Numbers like 0.001, 0.999, 123.456, etc...)

The Maximal divisibility supported by our SDK is 8 decimal points (mirroring the fact that 1 bitcoin is divisible to 100,000,000 satoshis).

The one thing to remember when issuing a divisible asset is that

the amount value always refers to the lowest denomination

For example, if we issue a divisibility 3 asset and specify amount 1, only 0.001 units of that asset will be issued.

Here is an example:

var Colu = require('colu')
var settings = {
network: 'testnet',
privateSeed: 'abcd4986fdac1b3a710892ef6eaa708d619d67100d0514ab996582966f927982'
}
var colu = new Colu(settings)

var asset = {
amount: 1,
divisibility:3
}

colu.on('connect', function () {
colu.issueAsset(asset, function (err, body) {
if (err) return console.error(err)
console.log("Body: ",body)
})
})

colu.init()

The response is:

Body:  { txHex: '01000000012d741dd70e927582dc810613dad5fa532b118e270de8df78f13425cddccf879d0000000000ffffffff0358020000000000001976a91496086b626ddb0003826c98d3f9d7acb970da223688ac00000000000000000b6a0943430105201300017078050000000000001976a91496086b626ddb0003826c98d3f9d7acb970da223688ac00000000',
assetId: 'LFiGGoWR3dQhGwCcnNEwaxubqPRr4zMZEHXTV',
multisigOutputs: [],
txid: '5c7a40c40a271fa67aeddb55d0e3d1d429a3f4c6932d5716dd42bef6f248c3bb',
receivingAddresses: [ { address: 'muCFjpj3p1wCWYBRD7AS4CLr79LRwyMVa5', amount: 1 } ],
issueAddress: 'muCFjpj3p1wCWYBRD7AS4CLr79LRwyMVa5' }

Let's look at the asset in the explorer:

ASSET NAME: N/A               LOCKED ASSET
ISSUANCE
Name Issuer Amount utxo
LFiGGoWR3dQhGwCcnNEwax... 0.001 5c7a40c40a271fa67aeddb55d0e3d1d429a3f4c6932d5716dd42bef6f248c3bb

HOLDERS
Address Amount
muCFjpj3p1wCWYBRD7AS4CLr79LRwyMVa5 0.001

TRANSFER TRANSACTIONS
No Transactions Found

ISSUE TRANSACTIONS
5c7a40c40a271fa67aeddb55d0e3d1...
Sent 0.00002 Asset Sent 0.001

As another example, let's issue 10 units of a new asset that will be divisible to 1 decimal place, and in the same transaction also transfer 0.1 units to one address and 1 unit to another address:

var Colu = require('colu')
var settings = {
network: 'testnet',
privateSeed: 'abcd4986fdac1b3a710892ef6eaa708d619d67100d0514ab996582966f927982'
}
var colu = new Colu(settings)

var asset = {
amount: 100,
divisibility:1,
transfer: [{
address: 'miPznpFr7xQpWXp3dfYXBXKiVcdLKNPazT', amount: 1
},{
address: 'mmf1tBpqZqsKuHsrADZTYbm8sdCznci8nn', amount: 10
}]
}

colu.on('connect', function () {
colu.issueAsset(asset, function (err, body) {
if (err) return console.error(err)
console.log("Body: ",body)
})
})

colu.init()

The response is:

Body:  { txHex: '010000000164cca9e24675e2448fcf16d3d9af1f1949f46747e78f964e4c67f15ad6bf20e50000000000ffffffff0558020000000000001976a9141f978c90a1bf14a9f65ec9d24f07050a7242fde388ac58020000000000001976a914435713f35be02b0cd541d20ef55d87cea01ffcb088ac58020000000000001976a9144f5a837573766e16244dd953dbe08d504a26e97688ac0000000000000000106a0e4343010520130001010a02259030c8000000000000001976a9144f5a837573766e16244dd953dbe08d504a26e97688ac00000000',
assetId: 'LJja9jcs6g7iDxHfaAECzwfLbq1YuZbvR9jXs',
multisigOutputs: [],
txid: '25cea5a15841525d5d4105714cf43216a5f008c26c62995657fbfb40d4f79372',
receivingAddresses:
[ { address: 'miPznpFr7xQpWXp3dfYXBXKiVcdLKNPazT', amount: 1 },
{ address: 'mmf1tBpqZqsKuHsrADZTYbm8sdCznci8nn', amount: 10 },
{ address: 'mnkY7CR2qe4g4WXxH7CAcwioxkyBRyto4y', amount: 89 } ],
issueAddress: 'mnkY7CR2qe4g4WXxH7CAcwioxkyBRyto4y' }

Let's look at the new asset in the explorer:

ASSET NAME: N/A                          LOCKED ASSET
ISSUANCE
Name Issuer Amount utxo
LJja9jcs6g7iDxHfaAECzw... 0.1 25cea5a15841525d5d4105714cf43216a5f008c26c62995657fbfb40d4f79372

HOLDERS
Address Amount
miPznpFr7xQpWXp3dfYXBXKiVcdLKNPazT 0.1
mmf1tBpqZqsKuHsrADZTYbm8sdCznci8nn 1.0
mnkY7CR2qe4g4WXxH7CAcwioxkyBRyto4y 8.9

TRANSFER TRANSACTIONS
No Transactions Found

ISSUE TRANSACTIONS
25cea5a15841525d5d4105714cf432...
Sent 0.00002 Asset Sent 10.0

Note that in the asset definition we were careful to specify all amounts in the lowest denomination (e.g. we wanted 10 units of a divisibility 1 asset so we specified the amount to be 100).

 

 

 

 

Send an Asset

In this section we will learn how to send an asset from one address to one or more other addresses by invoking the sendAsset method of a colu object.

For the purpose of this section, let's issue 500 units of a new asset, representing a ticket to a Broadway show

var Colu = require('colu')
var settings = {
network: 'testnet',
privateSeed: 'abcd4986fdac1b3a710892ef6eaa708d619d67100d0514ab996582966f927982'
}
var colu = new Colu(settings)

var asset = {
amount: 500,
metadata: {
'assetName': 'Chicago: The Musical',
'issuer': 'AMBASSADOR THEATRE, 219 West 49th Street, New York, NY 10019',
'description': 'Tickets to the show on 1/1/2016 at 8 PM'
}
}

colu.on('connect', function () {
colu.issueAsset(asset, function (err, body) {
if (err) return console.error(err)
console.log("Body: ",body)
})
})

colu.init()

Let's issue the asset by running the code, we get the following response:

{ txHex: '0100000001ea026b5c92d40f01243380b000507fdbb5d7615875be93112786c82ea28c98d1000000001976a9140eb3ffd2c449f56cfdf7f9cb8179fbcabce9c61a88acffffffff04ac0200000000000047512103ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2103263cd91de248d96c41b7b6fd4e6560c5ab624fec4ba038cbaf3516f10dfd8e3152ae58020000000000001976a9140eb3ffd2c449f56cfdf7f9cb8179fbcabce9c61a88ac0000000000000000206a1e4343010207af7a379075a2b5d55c152bee206f84f59bb3c8205201205210cc020000000000001976a9140eb3ffd2c449f56cfdf7f9cb8179fbcabce9c61a88ac00000000',
assetId: 'LE5arg1fawheJDvZEs9saPBoq9AENQGNxN9zr',
multisigOutputs: [],
txid: '99a508dfece3d5e4ea02aeec2eab3edc65926c174475ee0334fb1217345cfa65',
receivingAddresses: [ { address: 'mgrhPJzH37YctFsNtZGAHgvgEhJQ2A62ss', amount: 500 } ],
issueAddress: 'mgrhPJzH37YctFsNtZGAHgvgEhJQ2A62ss' }

Confirming that we our new Chicago: The Musical asset was issued with 500 units.

Now let's send 1 of those units (or tickets) from the issuance address mgrhPJzH37YctFsNtZGAHgvgEhJQ2A62ss to a new address, say mfhdwaZd9csRDGVPBGVZeup45JpEGvYqhA (for example, this could be the wallet address of a customer), by invoking sendAsset.

One of the strengths of the new colored coins protocol is the ability to add metadata to every colored transaction. We will use this here and add another piece of metadata, specifying the exact seat in the theater.

To invoke this method we need to specify:


  • The Asset ID

  • The Source Address (from which we send)

  • The Target Address / Phone Number (to which we send)

  • The Amount of units to be sent

  • New Metadata (optional)

Here is the send call:

var Colu = require('colu')
var settings = {
network: 'testnet',
privateSeed: 'abcd4986fdac1b3a710892ef6eaa708d619d67100d0514ab996582966f927982'
}
var colu = new Colu(settings)

var assetId = 'LE5arg1fawheJDvZEs9saPBoq9AENQGNxN9zr'
var fromAddress = 'mgrhPJzH37YctFsNtZGAHgvgEhJQ2A62ss'
var toAddress = 'mfhdwaZd9csRDGVPBGVZeup45JpEGvYqhA'
var phoneNumber = '+1234567890'

var send = {
from: [fromAddress],
to: [{
address: toAddress,
assetId: assetId,
amount: 1
},{
phoneNumber: phoneNumber,
assetId: assetId,
amount: 1
}],
metadata: {
'assetName': '1 Ticket to see the Chicago Musical on 1/1/2016 at 8 PM',
'issuer': 'Ticket booth on Times Square',
'description': 'Seat 12 at row 10'
}
};

colu.on('connect', function () {
colu.sendAsset(send, function (err, body) {
if (err) return console.error(err)
console.log("Body: ",body)
})
})

colu.init()

Note that we also added new metadata specifying extra information (the position of the particular seat in the theater).

Here is the response:

{ txHex: '010000000265fa5c341712fb3403ee7544176c9265dc3eab2eecae02eae4d5e3ecdf08a599010000001976a9140eb3ffd2c449f56cfdf7f9cb8179fbcabce9c61a88acffffffff8ef416f61e8ea138f65b05b661779dc2089a0c561307c93f6f1c80d938c6e75e000000001976a9140eb3ffd2c449f56cfdf7f9cb8179fbcabce9c61a88acffffffff04ac0200000000000047512103ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff21038389254c985afc9cec0ab69ee9feda2350328bb9004fe53cd72a1843cc5f2f4a52ae58020000000000001976a91402054158a7b64cc8a06827278145b880c3453b8b88ac00000000000000001c6a1a4343011186ac9b6ace74847c85c1825ce949db9b9d2e5ec4010124050000000000001976a9140eb3ffd2c449f56cfdf7f9cb8179fbcabce9c61a88ac00000000',
metadataSha1: '86ac9b6ace74847c85c1825ce949db9b9d2e5ec4',
multisigOutputs: [],
txid: 'b15a12441343e23fab484fd0be150d505fbb2d4769e67da0a69a413cb9b4724e' }

You can use the explorer to confirm that indeed 1 unit of our Chicago: The Musical asset was sent to the new address mfhdwaZd9csRDGVPBGVZeup45JpEGvYqhA.

ASSET NAME: Chicago: The Musical                                                  LOCKED ASSET
ISSUANCE

Name Issuer Amount utxo
Chicago: The Musical AMBASSADOR THEATRE, 219 West 49th Street, New York, NY 10019 500 99a508dfece3d5e4ea02aeec2eab3edc65926c174475ee0334fb1217345cfa65

HOLDERS
Address Amount
mfhdwaZd9csRDGVPBGVZeup45JpEGvYqhA 1
mgrhPJzH37YctFsNtZGAHgvgEhJQ2A62ss 499

In the next section we describe how to retrieve asset data and metadata.

 

 

 

 

Query an Asset

Assets are publicly available on the Blockchain and their metadata publicly available on Bittorent. Therefore, in order to query an asset, we don't need to specify a specific wallet seed, So let's just specify the Colored Coins API and Colu Server URLs

var settings = {
network: 'testnet'
}

In the next few sections we describe how to query for asset data and metadata. We begin with the general getassetdata method that retrieves the full set of data and metadata about an asset.

 

 

 

 

Asset Data

A complete record of the data about an asset can be fetched by calling the getAssetData method of the colu.coloredCoins object with the Asset ID.

Let's try that with the U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt asset that was created in the Issue an Asset|Issue and Transfer section.

var Colu = require('colu')
var settings = {
network: 'testnet'
}
var colu = new Colu(settings)

var asset = {
assetId: 'U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt'
}

colu.on('connect', function () {
colu.coloredCoins.getAssetData(asset,function (err, body) {
if (err) return console.error(err)
var util = require('util')
console.log("AssetData: ",util.inspect(body, {depth:10}))
})
})

colu.init()

Here is the response (note the addition of util.inspect to the log method so that also nested elements are fully displayed):

AssetData:  { assetId: 'U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt',
assetAmount: 1000000,
assetTotalAmount: 1000000,
assetData:
[ { address: 'mvaHph557j63CyJxmEaJ8F38SC3cNetvaa',
amount: 250000,
utxo: '2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453:0',
metadata:
{ assetId: 'U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt',
divisibility: 0,
lockStatus: false,
someUtxo: '2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453:0',
totalSupply: 1000000,
numOfHolders: 2,
numOfTransfers: 0,
numOfIssuance: 1,
firstBlock: 508051,
issuanceTxid: '2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453' } },
{ address: 'mw7hLtuo9vnBNCs9PL7i2h7oqDfs4j8NJG',
amount: 750000,
utxo: '2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453:2',
metadata:
{ assetId: 'U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt',
divisibility: 0,
lockStatus: false,
someUtxo: '2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453:0',
totalSupply: 1000000,
numOfHolders: 2,
numOfTransfers: 0,
numOfIssuance: 1,
firstBlock: 508051,
issuanceTxid: '2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453' } } ] }

The response details all the available data about the asset. Starting from the Asset ID and the total amount of available units (we will explain the difference between Amount and TotalAmount shortly) through the list of holding addresses and their crediting UTXOs.

In the above example, there are two different UTXOs, both from the same transaction 2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453:


  • 2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453:0
    The first output (index 0) where 250,000 units where transferred to the address mvaHph557j63CyJxmEaJ8F38SC3cNetvaa

  • 2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453:2
    The third output (index 2) where 750,000 units remained in the issuance address mw7hLtuo9vnBNCs9PL7i2h7oqDfs4j8NJG

The getAssetData method allows us to filter down the results by specifying two more parameters:


  • A list of addresses: Filter down to a subset of addresses by specifying a list of addresses under an addresses key

  • A Minimal number of confirmations: Filter down to data with a minimal number of confirmations (so that we only get UTXOs that were baked into blocks with at least the specified number of confirmations) by specifying the desired minimal number of confirmations under a numConfirmations key
  • As an example, let's look at the same query from before but filter down to only the issuance address mw7hLtuo9vnBNCs9PL7i2h7oqDfs4j8NJG and with at least 6 confirmations:

    var Colu = require('colu')
    var settings = {
    network: 'testnet'
    }
    var colu = new Colu(settings)

    var assetId = 'U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt'
    var addresses = ['mw7hLtuo9vnBNCs9PL7i2h7oqDfs4j8NJG']
    var confirmations = 6

    var asset = {
    assetId: assetId,
    addresses: addresses,
    numConfirmations:confirmations
    }

    colu.on('connect', function () {
    colu.coloredCoins.getAssetData(asset,function (err, body) {
    if (err) return console.error(err)
    var util = require('util')
    console.log("AssetData: ",util.inspect(body, {depth:10}))
    })
    })

    colu.init()

    The response is:

    AssetData:  { assetId: 'U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt',
    assetAmount: 750000,
    assetTotalAmount: 1000000,
    assetData:
    [ { address: 'mw7hLtuo9vnBNCs9PL7i2h7oqDfs4j8NJG',
    amount: 750000,
    utxo: '2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453:2',
    metadata:
    { assetId: 'U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt',
    divisibility: 0,
    lockStatus: false,
    someUtxo: '2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453:0',
    totalSupply: 1000000,
    numOfHolders: 2,
    numOfTransfers: 0,
    numOfIssuance: 1,
    firstBlock: 508051,
    issuanceTxid: '2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453' } } ] }

    This example also clarifies the difference between assetAmount and assetTotalAmount. The former counts only units that match the filter.

    Finally, note that the assets we queried so far had no colored coins metadata. Let's run an example against an asset with metadata, like the LEUWnac9Pp7kZYC3W19xtVMVqL8jw6m19RZHu asset we just issued in the Issue with Metadata section:

    var Colu = require('colu')
    var settings = {
    network: 'testnet'
    }
    var colu = new Colu(settings)

    var asset = {
    assetId: 'LEUWnac9Pp7kZYC3W19xtVMVqL8jw6m19RZHu'
    }

    colu.on('connect', function () {
    colu.coloredCoins.getAssetData(asset,function (err, body) {
    if (err) return console.error(err)
    var util = require('util')
    console.log("Body: ",util.inspect(body, {depth:10}))
    })
    })

    colu.init()

    The response indeed contains the issuance metadata:

    { assetId: 'LEUWnac9Pp7kZYC3W19xtVMVqL8jw6m19RZHu',
    assetAmount: 500,
    assetTotalAmount: 500,
    assetData:
    [ { address: 'n2SRqdXxbKpZPyVNBCdTM9Y5vHUcLEWVvE',
    amount: 500,
    utxo: 'f9fff185dc1df89ffe13cd7e5668a0af2953622176de91232ec1be975c6114c4:1',
    metadata:
    { assetId: 'LEUWnac9Pp7kZYC3W19xtVMVqL8jw6m19RZHu',
    divisibility: 0,
    lockStatus: null,
    someUtxo: 'f9fff185dc1df89ffe13cd7e5668a0af2953622176de91232ec1be975c6114c4:1',
    totalSupply: 500,
    numOfHolders: 1,
    numOfTransfers: 0,
    numOfIssuance: 1,
    firstBlock: 508271,
    issuanceTxid: 'f9fff185dc1df89ffe13cd7e5668a0af2953622176de91232ec1be975c6114c4',
    metadataOfIssuence:
    { data:
    { assetName: 'Mission Impossible 15',
    issuer: 'Fox Theatres',
    description: 'Movie ticket to see the New Tom Cruise flick' } },
    sha2Issue: '034976c163e25cfd8ff92c1962c2cbbb8fd60f3cf6a818e0bcac5fcb7e239ef332' } } ] }

    Note the sha2Issue field. This is a hash of the metadata that is embedded in the blockchain (check out the first output script) so that we can verify that the torrent data (stored on the Bittorrent network, not on the blockchain) is the correct data.

    The getAssetData method is useful because it return a comprehensive answer about an asset's data. In the next couple of sections we cover some specialized queries that return smaller subsets of the full data relevant to an asset.

 

 

 

 

Asset Metadata

In this section we will learn about a specialized query tailored to getting asset metadata.

One of the strengths of the new colored coins protocol is the ability to add metadata to every colored transaction. Therefore, when we query for an asset's metadata we must specify not only the asset ID but the specific UTXO.

In the Asset Data section we retrieved data for the LEUWnac9Pp7kZYC3W19xtVMVqL8jw6m19RZHu asset.
Let's use that asset ID and the UTXO f9fff185dc1df89ffe13cd7e5668a0af2953622176de91232ec1be975c6114c4:1 to query for the metadata:

var assetId = 'LEUWnac9Pp7kZYC3W19xtVMVqL8jw6m19RZHu'
var utxo = 'f9fff185dc1df89ffe13cd7e5668a0af2953622176de91232ec1be975c6114c4:1'

and query the asset's metadata by invoking the getAssetMetadata method on the colu.coloredCoins object like so:

var Colu = require('colu')
var settings = {
network: 'testnet'
}
var colu = new Colu(settings)

var assetId = 'LEUWnac9Pp7kZYC3W19xtVMVqL8jw6m19RZHu'
var utxo = 'f9fff185dc1df89ffe13cd7e5668a0af2953622176de91232ec1be975c6114c4:1'

colu.on('connect', function () {
colu.coloredCoins.getAssetMetadata(assetId,utxo,function (err, body) {
if (err) return console.error(err)
console.log("Body: ",body)
})
})

colu.init()

Here is the response:

Body:  { assetId: 'LEUWnac9Pp7kZYC3W19xtVMVqL8jw6m19RZHu',
divisibility: 0,
lockStatus: true,
someUtxo: 'f9fff185dc1df89ffe13cd7e5668a0af2953622176de91232ec1be975c6114c4:1',
totalSupply: 500,
numOfHolders: 1,
numOfTransfers: 0,
numOfIssuance: 1,
firstBlock: 508271,
issuanceTxid: 'f9fff185dc1df89ffe13cd7e5668a0af2953622176de91232ec1be975c6114c4',
metadataOfIssuence:
{ data:
{ assetName: 'Mission Impossible 15',
issuer: 'Fox Theatres',
description: 'Movie ticket to see the New Tom Cruise flick' } },
sha2Issue: '034976c163e25cfd8ff92c1962c2cbbb8fd60f3cf6a818e0bcac5fcb7e239ef332' }

We recognize the data that we added at issuance in the Issue an Asset|Issue with Metadata section.
In more general cases (e.g. try this asset) we also get a metadataOfUtxo key detailing metadata that was added in transfer transactions.

 

 

 

 

Asset Holders

In this section we will work with a specialized query that returns only the list of addresses holding an asset.

For example, let's look at the U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt asset that was created in the Issue an Asset|Issue and Transfer section.

We can query for the list of addresses holding the asset and the amount of units held in each by invoking the getStakeHolders method on the colu.coloredCoins object like so:

var Colu = require('colu')
var settings = {
network: 'testnet'
}
var colu = new Colu(settings)

var assetId = 'U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt'

colu.on('connect', function () {
colu.coloredCoins.getStakeHolders(assetId,function (err, body) {
if (err) return console.error(err)
console.log("Body: ",body)
})
})

colu.init()

Here is the response:

Body:  { assetId: 'U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt',
holders:
[ { address: 'mvaHph557j63CyJxmEaJ8F38SC3cNetvaa',
amount: 250000 },
{ address: 'mw7hLtuo9vnBNCs9PL7i2h7oqDfs4j8NJG',
amount: 750000 } ],
divisibility: 0,
lockStatus: false,
someUtxo: '2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453:0' }

We recognize the two holding addresses mvaHph557j63CyJxmEaJ8F38SC3cNetvaa and mw7hLtuo9vnBNCs9PL7i2h7oqDfs4j8NJG holding 250,000 and 750,000 units respectively.

The response also includes the divisibility (zero in this case) and whether the asset is locked or not (unlocked in this case).

This method also supports filtering the results by the number of confirmations. We can add a minimal_confirmations parameter to the query like so

var assetId = 'U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt'
var minimal_confirmations=1

colu.on('connect', function () {
colu.coloredCoins.getStakeHolders(assetId,minimal_confirmations,function (err, body) {
if (err) return console.error(err)
console.log("Body: ",body)
})
})

In this case the response will only return the addresses that hold the asset with at least the desired number of confirmations.

 

 

 

 

Colu API

This is Colu API.
it was created for easy & fast issuance of assets using Colu's engine.

To use Colu API you first need to deploy, host and run colu-nodejs server.
This server run on Node.js, so make sure you install node js first.

To install Node.js, see Installing Node.js

In the first section we will deploy and run the server on your own localhost.
You can deploy the server at a remote host or at any cloud environment.
The server uses JSON-RPC 2.0 protocol.

Each server run represent a wallet, that hold a private key, for asset management.

This API allows simple issuance and transfer of assets, as well as asset metadata retrieval.
This API provide the same functionality as Colu SDK, with an easy-to-use restful API.

This is a list of features in the API:
• Digital asset issuance and transfer (with an ability to add unlimited metadata)
• Asset metadata retrieval - read metadata of existing assets
• All the Bitcoin related nitty gritty is automatically handled behind the scenes:
• Funding - No need to hold any bitcoins, issuance and transfer costs are covered by Colu's engine
• Addresses and Private Keys - We use a bitcoin HD wallet management (BIP44)
• Cryptography and Security - cryptographic aspects of signing Bitcoin transactions

All Colu API endpoints are POST methods.

Install & Run Colu Server

First we need to deploy, host and run the server that will run Colu API.
We will deploy colu-nodejs server on localhost by following those steps:

1. Open a command prompt (cmd.exe)

2. Write at the command prompt:

npm i -g colu

Wait for 'colu' module installation process to finish.

3. Now, we need to configure the system environment variables.

It’s not mandatory to set the system environment variables.
The server is launched by default on localhost:80

Lets configure the server port at the system environment variables, for Mac, Linux and for Windows:

For Mac & Linux:

Write at the command prompt:

export COLU_SDK_RPC_SERVER_HTTP_PORT=8081

For Windows:

a. Right click on 'This PC' (or 'My Computer' at Win7)
b. Click on 'Properties'
c. Click on 'Addvanced System Settings' (on the left upper area)
d. On 'Advance' tab, click on 'Environment Variables' (bottom area)
e. On 'System Variables' (bottom), click on 'New...'
f. Add 'COLU_SDK_RPC_SERVER_HTTP_PORT' to the 'Variable name', and '8081' to 'Variable value'

The port number doesn’t have to be 8081.
You can configure the server port to any number you choose.

Here are all relevant system environment variables:

COLU_SDK_NETWORK // 'testnet' or 'mainnet' (default = 'mainnet')
COLU_SDK_COLU_HOST // Colu engine API address
COLU_SDK_API_KEY // Your API key (valid for 'mainnet' only)
COLU_SDK_PRIVATE_SEED // Private seed for Base58 private key (private seed | private seed WIF)
COLU_SDK_PRIVATE_SEED_WIF // Base58 private key WIF (private seed | private seed WIF)
COLU_SDK_REDIS_PORT // Redis port
COLU_SDK_REDIS_HOST // Redis host
COLU_SDK_RPC_SERVER_HTTP_PORT // HTTP port (default = 80)
COLU_SDK_RPC_SERVER_HTTPS_PORT // HTTPS port (default = 443)
COLU_SDK_RPC_SERVER_HOST // Server host
COLU_SDK_RPC_USE_SSL // Use SSL and launch HTTPS server (default = false)
COLU_SDK_RPC_PRIVATE_KEY_PATH // SSL private key path (valid only if COLU_SDK_RPC_USE_SSL = true)
COLU_SDK_RPC_CERTIFICATE_PATH // SSL certificate path (valid only if COLU_SDK_RPC_USE_SSL = true)
COLU_SDK_RPC_USE_BASIC_AUTH // Use HTTP basic authentication (default = false)
COLU_SDK_RPC_USER_NAME // User name for HTTP basic authentication (valid only if COLU_SDK_RPC_USE_BASIC_AUTH = true)
COLU_SDK_RPC_PASSWORD // Password for HTTP basic authentication (valid only if COLU_SDK_RPC_USE_BASIC_AUTH = true)
COLU_SDK_RPC_USE_BOTH // Use both HTTP and HTTPS servers (valid only if COLU_SDK_RPC_USE_SSL = true, default = false)

4. Write at command prompt:

For Mac & Linux:

node $(which colu)

For Windows:

colu

The server is running and ready when you see the following output:

http server started on port 8081

Now, the server is installed and running.

You can run the same process on a remote or a cloud server

In the next sections, we will start using its API methods.

 

 

 

 

Get Private Seed

privateseed API Documentation

TITLEPost Address

VERSION0.1.0

URL/

TYPE[POST]

Description

This API call is used to get the wallet private seed

Parameters
FieldTypeDescription
jsonrpc

String

jsonrpc version (must be exactly "2.0")

method

String

'hdwallet.getPrivateSeed'

id

String

request id, the server's response id will match this id

Examples
TitleTypeContent
Example usage: curl curl -X POST -i http://localhost:8081/ -H "Content-Type:application/json" --data '{ jsonrpc: "2.0", // mandatory method: "hdwallet.getPrivateSeed", // mandatory id: "1" // mandatory if response is needed }'
Success
FieldTypeDescription
jsonrpc

String

jsonrpc version

id

String

request id

result

String

hexadecimal base private seed

Get Private Seed

var request = require('request');

function postToApi(api_endpoint, json_data, callback) {
	console.log(api_endpoint+': ', JSON.stringify(json_data));
	request.post({
		url: 'http://localhost:8081/'+api_endpoint,
		headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
	}, 
	function (error, response, body) {
		if (error) {
			return callback(error);
		}
		if (typeof body === 'string') {
			body = JSON.parse(body);
		}
		return callback(null, body);
	});
};

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "hdwallet.getPrivateSeed",
// mandatory id: "1" // mandatory if response is needed } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(body) });

Response

{ 
  jsonrpc: '2.0',
  id: '1',
  result: '4835dd1e97f74f61bbf3579e688eeff36cbfe0cfac4dabccfab0d0db4125b683'
}

Get Private Seed

var request = require('request');

function postToApi(api_endpoint, json_data, callback) {
	console.log(api_endpoint+': ', JSON.stringify(json_data));
	request.post({
		url: 'http://localhost:8081/'+api_endpoint,
		headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
	}, 
	function (error, response, body) {
		if (error) {
			return callback(error);
		}
		if (typeof body === 'string') {
			body = JSON.parse(body);
		}
		return callback(null, body);
	});
};

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "hdwallet.getPrivateSeed",
// mandatory id: "1" // mandatory if response is needed } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(body) });

Response

{ 
  jsonrpc: '2.0',
  id: '1',
  result: '4835dd1e97f74f61bbf3579e688eeff36cbfe0cfac4dabccfab0d0db4125b683'
}

Get Private Seed

var request = require('request');

function postToApi(api_endpoint, json_data, callback) {
	console.log(api_endpoint+': ', JSON.stringify(json_data));
	request.post({
		url: 'http://localhost:8081/'+api_endpoint,
		headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
	}, 
	function (error, response, body) {
		if (error) {
			return callback(error);
		}
		if (typeof body === 'string') {
			body = JSON.parse(body);
		}
		return callback(null, body);
	});
};

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "hdwallet.getPrivateSeed",
// mandatory id: "1" // mandatory if response is needed } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(body) });

Response

{ 
  jsonrpc: '2.0',
  id: '1',
  result: '4835dd1e97f74f61bbf3579e688eeff36cbfe0cfac4dabccfab0d0db4125b683'
}

Get Private Seed

var request = require('request');

function postToApi(api_endpoint, json_data, callback) {
	console.log(api_endpoint+': ', JSON.stringify(json_data));
	request.post({
		url: 'http://localhost:8081/'+api_endpoint,
		headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
	}, 
	function (error, response, body) {
		if (error) {
			return callback(error);
		}
		if (typeof body === 'string') {
			body = JSON.parse(body);
		}
		return callback(null, body);
	});
};

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "hdwallet.getPrivateSeed",
// mandatory id: "1" // mandatory if response is needed } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(body) });

Response

{ 
  jsonrpc: '2.0',
  id: '1',
  result: '4835dd1e97f74f61bbf3579e688eeff36cbfe0cfac4dabccfab0d0db4125b683'
}

Save Private Seed

In order to use the same wallet at every server upload, we need to save the private seed at the System Environment Variable.

At the last section, we got the wallet private seed (privateSeed = '4835dd1e97f74f61bbf3579e688eeff36cbfe0cfac4dabccfab0d0db4125b683').

Now we can save the private seed to the System Environment Variables.

Lets do it for Mac, Linux and for Windows:

For Mac & Linux:

Open and write at the command prompt:

export COLU_SDK_PRIVATE_SEED=4835dd1e97f74f61bbf3579e688eeff36cbfe0cfac4dabccfab0d0db4125b683

For Windows:

a. Right click on 'This PC' (or 'My Computer' at Win7)
b. Click on 'Properties'
c. Click on 'Addvanced System Settings' (on the left upper area)
d. On 'Advance' tab, click on 'Environment Variables' (bottom area)
e. On 'System Variables' (bottom), click on 'New...'
f. Add 'COLU_SDK_PRIVATE_SEED' to the 'Variable name', and '4835dd1e97f74f61bbf3579e688eeff36cbfe0cfac4dabccfab0d0db4125b683' to 'Variable value'

Now we shall use the same wallet on each server upload.

 

 

 

 

Get Address

address API Documentation

TITLEPost Address

VERSION0.1.0

URL/

TYPE[POST]

Description

This API call is used to get the wallet address

Parameters
FieldTypeDescription
jsonrpc

String

jsonrpc version (must be exactly "2.0")

method

String

'hdwallet.getAddress'

id

String

request id, the server's response id will match this id

Examples
TitleTypeContent
Example usage: curl curl -X POST -i http://localhost:8081/ -H "Content-Type:application/json" --data '{ jsonrpc: "2.0", // mandatory method: "hdwallet.getAddress", // mandatory id: "1" // mandatory if response is needed }'
Success
FieldTypeDescription
jsonrpc

String

jsonrpc version

id

String

request id

result

String

Base58 addres

Get Address

var request = require('request');

function postToApi(api_endpoint, json_data, callback) {
	console.log(api_endpoint+': ', JSON.stringify(json_data));
	request.post({
		url: 'http://localhost:8081/'+api_endpoint,
		headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
	}, 
	function (error, response, body) {
		if (error) {
			return callback(error);
		}
		if (typeof body === 'string') {
			body = JSON.parse(body);
		}
		return callback(null, body);
	});
};

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "hdwallet.getAddress",
// mandatory id: "1" // mandatory if response is needed } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(body) });

Response

{ 
  jsonrpc: '2.0',
  id: '1',
  result: 'mqdt1TmZGcGuBCo7uA3BXryLaADsHeBHLE' 
}

Get Address

var request = require('request');

function postToApi(api_endpoint, json_data, callback) {
	console.log(api_endpoint+': ', JSON.stringify(json_data));
	request.post({
		url: 'http://localhost:8081/'+api_endpoint,
		headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
	}, 
	function (error, response, body) {
		if (error) {
			return callback(error);
		}
		if (typeof body === 'string') {
			body = JSON.parse(body);
		}
		return callback(null, body);
	});
};

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "hdwallet.getAddress",
// mandatory id: "1" // mandatory if response is needed } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(body) });

Response

{ 
  jsonrpc: '2.0',
  id: '1',
  result: 'mqdt1TmZGcGuBCo7uA3BXryLaADsHeBHLE' 
}

Get Address

var request = require('request');

function postToApi(api_endpoint, json_data, callback) {
	console.log(api_endpoint+': ', JSON.stringify(json_data));
	request.post({
		url: 'http://localhost:8081/'+api_endpoint,
		headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
	}, 
	function (error, response, body) {
		if (error) {
			return callback(error);
		}
		if (typeof body === 'string') {
			body = JSON.parse(body);
		}
		return callback(null, body);
	});
};

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "hdwallet.getAddress",
// mandatory id: "1" // mandatory if response is needed } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(body) });

Response

{ 
  jsonrpc: '2.0',
  id: '1',
  result: 'mqdt1TmZGcGuBCo7uA3BXryLaADsHeBHLE' 
}

Get Address

var request = require('request');

function postToApi(api_endpoint, json_data, callback) {
	console.log(api_endpoint+': ', JSON.stringify(json_data));
	request.post({
		url: 'http://localhost:8081/'+api_endpoint,
		headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
	}, 
	function (error, response, body) {
		if (error) {
			return callback(error);
		}
		if (typeof body === 'string') {
			body = JSON.parse(body);
		}
		return callback(null, body);
	});
};

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "hdwallet.getAddress",
// mandatory id: "1" // mandatory if response is needed } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(body) });

Response

{ 
  jsonrpc: '2.0',
  id: '1',
  result: 'mqdt1TmZGcGuBCo7uA3BXryLaADsHeBHLE' 
}

Issue Asset

issue API Documentation

TITLERequest to issue a coloredcoins asset

VERSION0.1.0

URL/

TYPE[POST]

Description

This API call is used to issue assets

Parameters
FieldTypeDescription
jsonrpc

String

jsonrpc version (must be exactly "2.0")

method

String

'issueAsset'

id

String

request id, the server's response id will match this id

params

JSON

asset object

    amount

Number

Asset amount

    issueAddress

String

Base58 public key address of asset issuer

    divisibility

Number

Asset divisibility

    reissueable

boolean

Define if the asset is unlock

    transfer

JSON[]

Transfer array

        address

String

Asset transfer address

        amount

Number

Asset transfer amount

    metadata(optional)

Object

Metadata of the specific utxo from the transaction

        assetId(optional)

String

Asset Id

        assetName(optional)

String

Asset Name

        assetGenesis(optional)

String

Genesis transaction where the asset was created (in case of re issue)

        issuer(optional)

String

Name of the issuer

        description(optional)

String

description of the asset

        urls(optional)

Object[]

Array of URL type objects

            name

String

Name of the url

            url

String

The url

            mimeType

String

Mime type of the data in the url

            dataHash(optional)

String

If needed hash of the data that in the url (for proof reasons)

        userData(optional)

JSON

Any arbitrary json data that the pervious owner of the output has entered

    rules(optional)

Object

Object for the rules of the asset

        version

Number

Version of the rule system

        fees

Object

            items(optional)

Object[]

Array of fee type items

                address

String

Address to send the fee

                assetId

String

Asset id to send fee (btc if none asset)

                value

Number

Value to send for the fee (in satoshi or amount)

            locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

        expiration(optional)

Object

Expiration object used to loan an asset, when asset expires it moves back to last output

            validUntil

Number

When the asset is consider expired

            locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

        minters(optional)

Object[]

Array of minter objects, (addresses that can issue the asset)

            address

String

Address of the minter

            locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type (if the minter can add minters)

        holders(optional)

Object[]

Array of holder type objects, they specify in what addresses the asset is considered valid

            address

String

Address where the asset is considered valid

            locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

callback

Object

callback function

Examples
TitleTypeContent
Example usage: curl curl -X POST -i http://localhost:8081/ -H "Content-Type:application/json" --data '{ jsonrpc: "2.0", // mandatory method: "issueAsset", // mandatory id: "1", // mandatory if response is needed params: // quary parameters { amount: 10, divisibility: 0, reissueable: false, transfer: [{ amount: 10 }], metadata: { "assetName": "Mission Impossible 15", "issuer": "Fox Theater", "description": "Movie ticket to see the New Tom Cruise flick", "userData": { "meta" : [ {key: "Item ID", value: 2, type: "Number"}, {key: "Item Name", value: "Item Name", type: "String"}, {key: "Company", value: "My Company", type: "String"}, {key: "Address", value: "San Francisco, CA", type: "String"} ] } } } }'
Success
FieldTypeDescription
jsonrpc

String

jsonrpc version

id

String

request id

result

String

output response

    txHex

String

Unsigned transaction hex for the issuance

    assetId

String

Asset id for the asset generated

    multisigOutputs

String[]

Multisig outputs of the asset data

    txId

String

Transaction id

    receivingAddresses

JSON[]

Asset recieving addresses & amounts

        address

String

Address that holds the asset

        amount

Number

Amount of asset on this address

    issueAddress

String

Address that issued the asset

Issue Asset

var request = require('request');

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var asset = {
    'amount': 100,
    'divisibility': 0,
    'reissueable':false,
    'transfer': [{
    	'amount': 100
    }],
    'metadata': {
        'assetName': 'Asset Name',
        'issuer': 'Asset Issuer',
        'description': 'My Description',
        'urls': [{name:'icon', url: 'https://pbs.twimg.com/profile_images/572390580823412736/uzfQSciL_bigger.png', mimeType: 'image/png', dataHash: ''}],
        'userData': {
            'meta' : [
                {key: 'Item ID', value: 2, type: 'Number'},
                {key: 'Item Name', value: 'Item Name', type: 'String'},
                {key: 'Company', value: 'My Company', type: 'String'},
                {key: 'Address', value: 'San Francisco, CA', type: 'String'}
            ]
        }
    }
};

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "issueAsset",
// mandatory id: "1", // mandatory if response is needed params: asset // asset json object } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(body) });

Response

{ 
    jsonrpc: '2.0',
    id: '1',
    result: { 
        txHex: '0100000001ac3acc7068b79d8c89e028382d4dd7a5a7faa6540e8ce32c5b9741e9dab557bf000000001976a914d8c7492faf180c18b65e17a60d95106e5439f70988acffffffff04ac0200000000000047512103ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff21038ad7eaf38215d649b8adc9e5e749cab52f70820372d974f7d4f5ac076b79c74752ae58020000000000001976a914d8c7492faf180c18b65e17a60d95106e5439f70988ac0000000000000000206a1e4343010294d115aab357359fd83d2e4b0f3ca6698ceaabec201201201210cc020000000000001976a914d8c7492faf180c18b65e17a60d95106e5439f70988ac00000000',
        assetId: 'LKFK1hp7z6z9nu2gbvjkVv4orLQX9Aim59YwA',
        coloredOutputIndexes: [ 1 ],
        financeTxid: 'bf57b5dae941975b2ce38c0e54a6faa7a5d74d2d3828e0898c9db76870cc3aac',
        txid: 'a5b37ce2888e0780d5d92150033ad6ee8d8cdfd54b5df3d96fd4219f2027c471',
        receivingAddresses: [
            {amount:100, address:'mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW'}
        ],
        issueAddress: 'n1HAz7eHfwnBDAp5RgjzVZ58EQ5tLWBn7N' 
    } 
}

Issue Asset

var request = require('request');

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var asset = {
    'amount': 100,
    'divisibility': 0,
    'reissueable':false,
    'transfer': [{
    	'amount': 100
    }],
    'metadata': {
        'assetName': 'Asset Name',
        'issuer': 'Asset Issuer',
        'description': 'My Description',
        'urls': [{name:'icon', url: 'https://pbs.twimg.com/profile_images/572390580823412736/uzfQSciL_bigger.png', mimeType: 'image/png', dataHash: ''}],
        'userData': {
            'meta' : [
                {key: 'Item ID', value: 2, type: 'Number'},
                {key: 'Item Name', value: 'Item Name', type: 'String'},
                {key: 'Company', value: 'My Company', type: 'String'},
                {key: 'Address', value: 'San Francisco, CA', type: 'String'}
            ]
        }
    }
};

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "issueAsset",
// mandatory id: "1", // mandatory if response is needed params: asset // asset json object } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(body) });

Response

{ 
    jsonrpc: '2.0',
    id: '1',
    result: { 
        txHex: '0100000001ac3acc7068b79d8c89e028382d4dd7a5a7faa6540e8ce32c5b9741e9dab557bf000000001976a914d8c7492faf180c18b65e17a60d95106e5439f70988acffffffff04ac0200000000000047512103ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff21038ad7eaf38215d649b8adc9e5e749cab52f70820372d974f7d4f5ac076b79c74752ae58020000000000001976a914d8c7492faf180c18b65e17a60d95106e5439f70988ac0000000000000000206a1e4343010294d115aab357359fd83d2e4b0f3ca6698ceaabec201201201210cc020000000000001976a914d8c7492faf180c18b65e17a60d95106e5439f70988ac00000000',
        assetId: 'LKFK1hp7z6z9nu2gbvjkVv4orLQX9Aim59YwA',
        coloredOutputIndexes: [ 1 ],
        financeTxid: 'bf57b5dae941975b2ce38c0e54a6faa7a5d74d2d3828e0898c9db76870cc3aac',
        txid: 'a5b37ce2888e0780d5d92150033ad6ee8d8cdfd54b5df3d96fd4219f2027c471',
        receivingAddresses: [
            {amount:100, address:'mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW'}
        ],
        issueAddress: 'n1HAz7eHfwnBDAp5RgjzVZ58EQ5tLWBn7N' 
    } 
}

Issue Asset

var request = require('request');

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var asset = {
    'amount': 100,
    'divisibility': 0,
    'reissueable':false,
    'transfer': [{
    	'amount': 100
    }],
    'metadata': {
        'assetName': 'Asset Name',
        'issuer': 'Asset Issuer',
        'description': 'My Description',
        'urls': [{name:'icon', url: 'https://pbs.twimg.com/profile_images/572390580823412736/uzfQSciL_bigger.png', mimeType: 'image/png', dataHash: ''}],
        'userData': {
            'meta' : [
                {key: 'Item ID', value: 2, type: 'Number'},
                {key: 'Item Name', value: 'Item Name', type: 'String'},
                {key: 'Company', value: 'My Company', type: 'String'},
                {key: 'Address', value: 'San Francisco, CA', type: 'String'}
            ]
        }
    }
};

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "issueAsset",
// mandatory id: "1", // mandatory if response is needed params: asset // asset json object } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(body) });

Response

{ 
    jsonrpc: '2.0',
    id: '1',
    result: { 
        txHex: '0100000001ac3acc7068b79d8c89e028382d4dd7a5a7faa6540e8ce32c5b9741e9dab557bf000000001976a914d8c7492faf180c18b65e17a60d95106e5439f70988acffffffff04ac0200000000000047512103ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff21038ad7eaf38215d649b8adc9e5e749cab52f70820372d974f7d4f5ac076b79c74752ae58020000000000001976a914d8c7492faf180c18b65e17a60d95106e5439f70988ac0000000000000000206a1e4343010294d115aab357359fd83d2e4b0f3ca6698ceaabec201201201210cc020000000000001976a914d8c7492faf180c18b65e17a60d95106e5439f70988ac00000000',
        assetId: 'LKFK1hp7z6z9nu2gbvjkVv4orLQX9Aim59YwA',
        coloredOutputIndexes: [ 1 ],
        financeTxid: 'bf57b5dae941975b2ce38c0e54a6faa7a5d74d2d3828e0898c9db76870cc3aac',
        txid: 'a5b37ce2888e0780d5d92150033ad6ee8d8cdfd54b5df3d96fd4219f2027c471',
        receivingAddresses: [
            {amount:100, address:'mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW'}
        ],
        issueAddress: 'n1HAz7eHfwnBDAp5RgjzVZ58EQ5tLWBn7N' 
    } 
}

Issue Asset

var request = require('request');

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var asset = {
    'amount': 100,
    'divisibility': 0,
    'reissueable':false,
    'transfer': [{
    	'amount': 100
    }],
    'metadata': {
        'assetName': 'Asset Name',
        'issuer': 'Asset Issuer',
        'description': 'My Description',
        'urls': [{name:'icon', url: 'https://pbs.twimg.com/profile_images/572390580823412736/uzfQSciL_bigger.png', mimeType: 'image/png', dataHash: ''}],
        'userData': {
            'meta' : [
                {key: 'Item ID', value: 2, type: 'Number'},
                {key: 'Item Name', value: 'Item Name', type: 'String'},
                {key: 'Company', value: 'My Company', type: 'String'},
                {key: 'Address', value: 'San Francisco, CA', type: 'String'}
            ]
        }
    }
};

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "issueAsset",
// mandatory id: "1", // mandatory if response is needed params: asset // asset json object } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(body) });

Response

{ 
    jsonrpc: '2.0',
    id: '1',
    result: { 
        txHex: '0100000001ac3acc7068b79d8c89e028382d4dd7a5a7faa6540e8ce32c5b9741e9dab557bf000000001976a914d8c7492faf180c18b65e17a60d95106e5439f70988acffffffff04ac0200000000000047512103ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff21038ad7eaf38215d649b8adc9e5e749cab52f70820372d974f7d4f5ac076b79c74752ae58020000000000001976a914d8c7492faf180c18b65e17a60d95106e5439f70988ac0000000000000000206a1e4343010294d115aab357359fd83d2e4b0f3ca6698ceaabec201201201210cc020000000000001976a914d8c7492faf180c18b65e17a60d95106e5439f70988ac00000000',
        assetId: 'LKFK1hp7z6z9nu2gbvjkVv4orLQX9Aim59YwA',
        coloredOutputIndexes: [ 1 ],
        financeTxid: 'bf57b5dae941975b2ce38c0e54a6faa7a5d74d2d3828e0898c9db76870cc3aac',
        txid: 'a5b37ce2888e0780d5d92150033ad6ee8d8cdfd54b5df3d96fd4219f2027c471',
        receivingAddresses: [
            {amount:100, address:'mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW'}
        ],
        issueAddress: 'n1HAz7eHfwnBDAp5RgjzVZ58EQ5tLWBn7N' 
    } 
}

Send Asset

send API Documentation

TITLERequest to send a digital asset

VERSION0.1.0

URL/

TYPE[POST]

Description

This API call is used to send assets between users

Parameters
FieldTypeDescription
jsonrpc

String

jsonrpc version (must be exactly "2.0")

method

String

'sendAsset'

id

String

request id, the server's response id will match this id

params

JSON

asset object

    from(optional)

String[]

Array of address to send the asset from. Any unspents of the specific asset held by that address will be used (optional can used sendutxo instead)

    sendutxo(optional)

String[]

Array of Utxos to use for sending the asset itself (:format)

    to

JSON[]

transfer array

        address

String

Asset transfer address

        phoneNumber

String

Asset transfer mobile device

        assetId

String

Asset id

        amount

Number

Asset transfer amount

    metadata(optional)

Object

Metadata of the specific utxo from the transaction

        assetId(optional)

String

Asset Id

        assetName(optional)

String

Asset Name

        assetGenesis(optional)

String

Genesis transaction where the asset was created (in case of re issue)

        issuer(optional)

String

Name of the issuer

        description(optional)

String

description of the asset

        urls(optional)

Object[]

Array of URL type objects

            name

String

Name of the url

            url

String

The url

            mimeType

String

Mime type of the data in the url

            dataHash(optional)

String

If needed hash of the data that in the url (for proof reasons)

        userData(optional)

JSON

Any arbitrary json data that the pervious owner of the output has entered

    rules(optional)

Object

Object for the rules of the asset

        version

Number

Version of the rule system

        fees

Object

            items(optional)

Object[]

Array of fee type items

                address

String

Address to send the fee

                assetId

String

Asset id to send fee (btc if none asset)

                value

Number

Value to send for the fee (in satoshi or amount)

            locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

        expiration(optional)

Object

Expiration object used to loan an asset, when asset expires it moves back to last output

            validUntil

Number

When the asset is consider expired

            locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

        minters(optional)

Object[]

Array of minter objects, (addresses that can issue the asset)

            address

String

Address of the minter

            locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type (if the minter can add minters)

        holders(optional)

Object[]

Array of holder type objects, they specify in what addresses the asset is considered valid

            address

String

Address where the asset is considered valid

            locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

callback

Object

callback function

Examples
TitleTypeContent
Example usage: curl curl -X POST -i http://localhost:8081/ -H "Content-Type:application/json" --data '{ jsonrpc: "2.0", // mandatory method: "sendAsset", // mandatory id: "1", // mandatory if response is needed params: // quary parameters { from: "n3TjZPvivsP5xHgRS5zbs83vcYcqDzC8J4", to: [{ address: "miatv9LDBTe6YwT9begBxPhdfA5tBU9jJi", assetId: "LJ2kQLhyPhcJg2faZ1c6bXLzcCVBi27xUZZme", amount: 2 }], metadata: { "assetName": "Mission Impossible 16", "issuer": "Fox Theater", "description": "Movie ticket to see the New Tom Cruise flick again", "userData": { "meta" : [ {key: "Item ID", value: 2, type: "Number"}, {key: "Item Name", value: "Item Name", type: "String"}, {key: "Company", value: "My Company", type: "String"}, {key: "Address", value: "San Francisco, CA", type: "String"} ] } } } }'
Success
FieldTypeDescription
jsonrpc

String

jsonrpc version

id

String

request id

result

String

output response

    txHex

String

Unsigned transaction hex for the issuance

    metadataSha1

String

Hashing data of the asset metadata

    multisigOutputs

String[]

Multisig outputs of the asset data

    txId

String

Transaction id

Send Asset

var request = require('request');

var address = "mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW";
var address1 = "mhTVVgEn9WJHEQaTvURhdGc8yqd9tTiyqu";
var assetId = "LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt";

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var sendAsset = {
    "from":[address],
    "to": [{
        "address":address1,
        "amount":10,
        "assetId":assetId
    }],
    "metadata":{
        "userData":{
            "meta":[{
                "key":"ID",
                "value":100,
                "type":"Number"
            },{
                "key":"Issuer Name",
                "value":"My Name",
                "type":"String"
            },{
                "key":"Address",
                "value":"San Francisco, CA",
                "type":"String"
            },{
                "key":"Name",
                "value":"WF Shares",
                "type":"String"
            },{
                "key":"Description",
                "value":"Dummy WF Shares",
                "type":"String"
            }]
        }
    }
}

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "sendAsset",
// mandatory id: "1", // mandatory if response is needed params: sendAsset // asset json object } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(JSON.stringify(body)) });

Response

{
    jsonrpc:'2.0',
    id: '1',
    result: {
txHex:'01000000028eb8630c3b717aca732d1756847b2fa09a61bf411e71cbf44d56978bbe4a92da010000001976a9140163a335af7b06bf036af48072ad0c7ed4e659c988acffffffffc76706af9c70ace15b65b1175ca2fa7dcea72a20c56083a5f823e2f2a8d4b720000000001976a9140163a335af7b06bf036af48072ad0c7ed4e659c988acffffffff04ac0200000000000047512103ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2103ff7e5db2203b4cf330203b4255269b8c88d89802757fdccf2dd4b57a91aebdd652ae58020000000000001976a9141548a1ebcc09d386e6bdd1ccf39e4e17dd60ed6588ac00000000000000001c6a1a434301113b2f0f74c075e385811e0b64e81a6f175f116706010a24050000000000001976a9140163a335af7b06bf036af48072ad0c7ed4e659c988ac00000000',
        metadataSha1: '3b2f0f74c075e385811e0b64e81a6f175f116706',
        multisigOutputs: [],
        coloredOutputIndexes: [1],
        financeTxid: '20b7d4a8f2e223f8a58360c5202aa7ce7dfaa25c17b1655be1ac709caf0667c7',
        txid: 'b905a0d835393245cef9901f891fa1058e33c2ac44fb01b437055aeeab401c55'
    }
}

Send Asset

var request = require('request');

var address = "mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW";
var address1 = "mhTVVgEn9WJHEQaTvURhdGc8yqd9tTiyqu";
var assetId = "LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt";

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var sendAsset = {
    "from":[address],
    "to": [{
        "address":address1,
        "amount":10,
        "assetId":assetId
    }],
    "metadata":{
        "userData":{
            "meta":[{
                "key":"ID",
                "value":100,
                "type":"Number"
            },{
                "key":"Issuer Name",
                "value":"My Name",
                "type":"String"
            },{
                "key":"Address",
                "value":"San Francisco, CA",
                "type":"String"
            },{
                "key":"Name",
                "value":"WF Shares",
                "type":"String"
            },{
                "key":"Description",
                "value":"Dummy WF Shares",
                "type":"String"
            }]
        }
    }
}

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "sendAsset",
// mandatory id: "1", // mandatory if response is needed params: sendAsset // asset json object } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(JSON.stringify(body)) });

Response

{
    jsonrpc:'2.0',
    id: '1',
    result: {
txHex:'01000000028eb8630c3b717aca732d1756847b2fa09a61bf411e71cbf44d56978bbe4a92da010000001976a9140163a335af7b06bf036af48072ad0c7ed4e659c988acffffffffc76706af9c70ace15b65b1175ca2fa7dcea72a20c56083a5f823e2f2a8d4b720000000001976a9140163a335af7b06bf036af48072ad0c7ed4e659c988acffffffff04ac0200000000000047512103ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2103ff7e5db2203b4cf330203b4255269b8c88d89802757fdccf2dd4b57a91aebdd652ae58020000000000001976a9141548a1ebcc09d386e6bdd1ccf39e4e17dd60ed6588ac00000000000000001c6a1a434301113b2f0f74c075e385811e0b64e81a6f175f116706010a24050000000000001976a9140163a335af7b06bf036af48072ad0c7ed4e659c988ac00000000',
        metadataSha1: '3b2f0f74c075e385811e0b64e81a6f175f116706',
        multisigOutputs: [],
        coloredOutputIndexes: [1],
        financeTxid: '20b7d4a8f2e223f8a58360c5202aa7ce7dfaa25c17b1655be1ac709caf0667c7',
        txid: 'b905a0d835393245cef9901f891fa1058e33c2ac44fb01b437055aeeab401c55'
    }
}

Send Asset

var request = require('request');

var address = "mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW";
var address1 = "mhTVVgEn9WJHEQaTvURhdGc8yqd9tTiyqu";
var assetId = "LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt";

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var sendAsset = {
    "from":[address],
    "to": [{
        "address":address1,
        "amount":10,
        "assetId":assetId
    }],
    "metadata":{
        "userData":{
            "meta":[{
                "key":"ID",
                "value":100,
                "type":"Number"
            },{
                "key":"Issuer Name",
                "value":"My Name",
                "type":"String"
            },{
                "key":"Address",
                "value":"San Francisco, CA",
                "type":"String"
            },{
                "key":"Name",
                "value":"WF Shares",
                "type":"String"
            },{
                "key":"Description",
                "value":"Dummy WF Shares",
                "type":"String"
            }]
        }
    }
}

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "sendAsset",
// mandatory id: "1", // mandatory if response is needed params: sendAsset // asset json object } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(JSON.stringify(body)) });

Response

{
    jsonrpc:'2.0',
    id: '1',
    result: {
txHex:'01000000028eb8630c3b717aca732d1756847b2fa09a61bf411e71cbf44d56978bbe4a92da010000001976a9140163a335af7b06bf036af48072ad0c7ed4e659c988acffffffffc76706af9c70ace15b65b1175ca2fa7dcea72a20c56083a5f823e2f2a8d4b720000000001976a9140163a335af7b06bf036af48072ad0c7ed4e659c988acffffffff04ac0200000000000047512103ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2103ff7e5db2203b4cf330203b4255269b8c88d89802757fdccf2dd4b57a91aebdd652ae58020000000000001976a9141548a1ebcc09d386e6bdd1ccf39e4e17dd60ed6588ac00000000000000001c6a1a434301113b2f0f74c075e385811e0b64e81a6f175f116706010a24050000000000001976a9140163a335af7b06bf036af48072ad0c7ed4e659c988ac00000000',
        metadataSha1: '3b2f0f74c075e385811e0b64e81a6f175f116706',
        multisigOutputs: [],
        coloredOutputIndexes: [1],
        financeTxid: '20b7d4a8f2e223f8a58360c5202aa7ce7dfaa25c17b1655be1ac709caf0667c7',
        txid: 'b905a0d835393245cef9901f891fa1058e33c2ac44fb01b437055aeeab401c55'
    }
}

Send Asset

var request = require('request');

var address = "mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW";
var address1 = "mhTVVgEn9WJHEQaTvURhdGc8yqd9tTiyqu";
var assetId = "LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt";

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var sendAsset = {
    "from":[address],
    "to": [{
        "address":address1,
        "amount":10,
        "assetId":assetId
    }],
    "metadata":{
        "userData":{
            "meta":[{
                "key":"ID",
                "value":100,
                "type":"Number"
            },{
                "key":"Issuer Name",
                "value":"My Name",
                "type":"String"
            },{
                "key":"Address",
                "value":"San Francisco, CA",
                "type":"String"
            },{
                "key":"Name",
                "value":"WF Shares",
                "type":"String"
            },{
                "key":"Description",
                "value":"Dummy WF Shares",
                "type":"String"
            }]
        }
    }
}

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "sendAsset",
// mandatory id: "1", // mandatory if response is needed params: sendAsset // asset json object } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(JSON.stringify(body)) });

Response

{
    jsonrpc:'2.0',
    id: '1',
    result: {
txHex:'01000000028eb8630c3b717aca732d1756847b2fa09a61bf411e71cbf44d56978bbe4a92da010000001976a9140163a335af7b06bf036af48072ad0c7ed4e659c988acffffffffc76706af9c70ace15b65b1175ca2fa7dcea72a20c56083a5f823e2f2a8d4b720000000001976a9140163a335af7b06bf036af48072ad0c7ed4e659c988acffffffff04ac0200000000000047512103ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2103ff7e5db2203b4cf330203b4255269b8c88d89802757fdccf2dd4b57a91aebdd652ae58020000000000001976a9141548a1ebcc09d386e6bdd1ccf39e4e17dd60ed6588ac00000000000000001c6a1a434301113b2f0f74c075e385811e0b64e81a6f175f116706010a24050000000000001976a9140163a335af7b06bf036af48072ad0c7ed4e659c988ac00000000',
        metadataSha1: '3b2f0f74c075e385811e0b64e81a6f175f116706',
        multisigOutputs: [],
        coloredOutputIndexes: [1],
        financeTxid: '20b7d4a8f2e223f8a58360c5202aa7ce7dfaa25c17b1655be1ac709caf0667c7',
        txid: 'b905a0d835393245cef9901f891fa1058e33c2ac44fb01b437055aeeab401c55'
    }
}

Burn Asset

burn API Documentation

TITLEBurn asset

VERSION0.1.0

URL/

TYPE[POST]

Description

This API call is used to burn an asset - reduce a specified amount of an asset from its total supply.

Parameters
FieldTypeDescription
jsonrpc

String

jsonrpc version (must be exactly "2.0")

method

String

'burnAsset'

id

String

request id, the server's response id will match this id

params

JSON

asset object

    from(optional)

String[]

Array of address to send the asset from. Any unspents of the specific asset held by that address will be used (optional can used sendutxo instead)

    sendutxo(optional)

String[]

Array of Utxos to use for sending the asset itself (:format)

    burn

JSON[]

burn array

        assetId

String

Asset Id to burn

        amount

Number

Asset amount to burn

    transfer(optional)

JSON[]

transfer array

        address(optional)

String

Asset transfer address

        phoneNumber(optional)

String

Asset transfer mobile device

        assetId(optional)

String

Asset id

        amount(optional)

Number

Asset transfer amount

    metadata(optional)

Object

Metadata of the specific utxo from the transaction

        assetId(optional)

String

Asset Id

        assetName(optional)

String

Asset Name

        assetGenesis(optional)

String

Genesis transaction where the asset was created (in case of re issue)

        issuer(optional)

String

Name of the issuer

        description(optional)

String

description of the asset

        urls(optional)

Object[]

Array of URL type objects

            name

String

Name of the url

            url

String

The url

            mimeType

String

Mime type of the data in the url

            dataHash(optional)

String

If needed hash of the data that in the url (for proof reasons)

        userData(optional)

JSON

Any arbitrary json data that the pervious owner of the output has entered

    rules(optional)

Object

Object for the rules of the asset

        version

Number

Version of the rule system

        fees

Object

            items(optional)

Object[]

Array of fee type items

                address

String

Address to send the fee

                assetId

String

Asset id to send fee (btc if none asset)

                value

Number

Value to send for the fee (in satoshi or amount)

            locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

        expiration(optional)

Object

Expiration object used to loan an asset, when asset expires it moves back to last output

            validUntil

Number

When the asset is consider expired

            locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

        minters(optional)

Object[]

Array of minter objects, (addresses that can issue the asset)

            address

String

Address of the minter

            locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type (if the minter can add minters)

        holders(optional)

Object[]

Array of holder type objects, they specify in what addresses the asset is considered valid

            address

String

Address where the asset is considered valid

            locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

Success
FieldTypeDescription
jsonrpc

String

jsonrpc version

id

String

Request id

result

String

Output response

    txHex

String

Hex of the burn transaction

    metadataSha1

String

Hashing data of the asset metadata

    multisigOutputs

String[]

Multisig outputs of the asset data

    txid

String

The burn transaction id

    financeTxid

String

The finance transaction id

Burn Asset

var request = require('request');

var address = "mvmFwY9gJCtKBdFPDDyCGuYXVCrB6ejScK";
var assetId = "La8nmmQ7HyVeyWVo4XC9k5rdRzrcjjAw73WgYt";

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        callback(null, body);
    });
};

var burnAsset = {
    "from":[address],
    "burn": [{
        "amount": 10,
        "assetId": assetId
    }]
}

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "burnAsset",
// mandatory id: "1", // mandatory if response is needed params: burnAsset // burn json object } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(JSON.stringify(body)) });

Response

{
    jsonrpc:'2.0',
    id: '1',
    result: { txHex: '0100000002346ab93dd39019102a78f64fb462922f8f2fc64f4de382998486ce7dca95428a000000001976a914a73e70ca6fdb743515508a47dd36e922527174b188acffffffffb3630450c091566c99f4807381647f1b440402d086394aa22480664484238b12000000001976a914a73e70ca6fdb743515508a47dd36e922527174b188acffffffff020000000000000000086a06434302251f0258020000000000001976a914a73e70ca6fdb743515508a47dd36e922527174b188ac00000000',
  multisigOutputs: [],
  coloredOutputIndexes: [],
  financeTxid: '128b238444668024a24a3986d00204441b7f64817380f4996c5691c0500463b3',
  txid: '4effebaa539b527a5a1990d8f232eb04fbc4e3966a9834926d451d902993b6cd' }
}

Burn Asset

var request = require('request');

var address = "mvmFwY9gJCtKBdFPDDyCGuYXVCrB6ejScK";
var assetId = "La8nmmQ7HyVeyWVo4XC9k5rdRzrcjjAw73WgYt";

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        callback(null, body);
    });
};

var burnAsset = {
    "from":[address],
    "burn": [{
        "amount": 10,
        "assetId": assetId
    }]
}

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "burnAsset",
// mandatory id: "1", // mandatory if response is needed params: burnAsset // burn json object } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(JSON.stringify(body)) });

Response

{
    jsonrpc:'2.0',
    id: '1',
    result: { txHex: '0100000002346ab93dd39019102a78f64fb462922f8f2fc64f4de382998486ce7dca95428a000000001976a914a73e70ca6fdb743515508a47dd36e922527174b188acffffffffb3630450c091566c99f4807381647f1b440402d086394aa22480664484238b12000000001976a914a73e70ca6fdb743515508a47dd36e922527174b188acffffffff020000000000000000086a06434302251f0258020000000000001976a914a73e70ca6fdb743515508a47dd36e922527174b188ac00000000',
  multisigOutputs: [],
  coloredOutputIndexes: [],
  financeTxid: '128b238444668024a24a3986d00204441b7f64817380f4996c5691c0500463b3',
  txid: '4effebaa539b527a5a1990d8f232eb04fbc4e3966a9834926d451d902993b6cd' }
}

Burn Asset

var request = require('request');

var address = "mvmFwY9gJCtKBdFPDDyCGuYXVCrB6ejScK";
var assetId = "La8nmmQ7HyVeyWVo4XC9k5rdRzrcjjAw73WgYt";

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        callback(null, body);
    });
};

var burnAsset = {
    "from":[address],
    "burn": [{
        "amount": 10,
        "assetId": assetId
    }]
}

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "burnAsset",
// mandatory id: "1", // mandatory if response is needed params: burnAsset // burn json object } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(JSON.stringify(body)) });

Response

{
    jsonrpc:'2.0',
    id: '1',
    result: { txHex: '0100000002346ab93dd39019102a78f64fb462922f8f2fc64f4de382998486ce7dca95428a000000001976a914a73e70ca6fdb743515508a47dd36e922527174b188acffffffffb3630450c091566c99f4807381647f1b440402d086394aa22480664484238b12000000001976a914a73e70ca6fdb743515508a47dd36e922527174b188acffffffff020000000000000000086a06434302251f0258020000000000001976a914a73e70ca6fdb743515508a47dd36e922527174b188ac00000000',
  multisigOutputs: [],
  coloredOutputIndexes: [],
  financeTxid: '128b238444668024a24a3986d00204441b7f64817380f4996c5691c0500463b3',
  txid: '4effebaa539b527a5a1990d8f232eb04fbc4e3966a9834926d451d902993b6cd' }
}

Burn Asset

var request = require('request');

var address = "mvmFwY9gJCtKBdFPDDyCGuYXVCrB6ejScK";
var assetId = "La8nmmQ7HyVeyWVo4XC9k5rdRzrcjjAw73WgYt";

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        callback(null, body);
    });
};

var burnAsset = {
    "from":[address],
    "burn": [{
        "amount": 10,
        "assetId": assetId
    }]
}

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "burnAsset",
// mandatory id: "1", // mandatory if response is needed params: burnAsset // burn json object } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(JSON.stringify(body)) });

Response

{
    jsonrpc:'2.0',
    id: '1',
    result: { txHex: '0100000002346ab93dd39019102a78f64fb462922f8f2fc64f4de382998486ce7dca95428a000000001976a914a73e70ca6fdb743515508a47dd36e922527174b188acffffffffb3630450c091566c99f4807381647f1b440402d086394aa22480664484238b12000000001976a914a73e70ca6fdb743515508a47dd36e922527174b188acffffffff020000000000000000086a06434302251f0258020000000000001976a914a73e70ca6fdb743515508a47dd36e922527174b188ac00000000',
  multisigOutputs: [],
  coloredOutputIndexes: [],
  financeTxid: '128b238444668024a24a3986d00204441b7f64817380f4996c5691c0500463b3',
  txid: '4effebaa539b527a5a1990d8f232eb04fbc4e3966a9834926d451d902993b6cd' }
}

Get Asset Data

assetdata API Documentation

TITLERequest asset data and metadata

VERSION0.1.0

URL/

TYPE[POST]

Description

This API call is used to get the data of the issuance of an asset

Parameters
FieldTypeDescription
jsonrpc

String

jsonrpc version (must be exactly "2.0")

method

String

'getAssetData'

id

String

request id, the server's response id will match this id

params

JSON

asset object

    assetId

String

Asset ID

    numConfirmations(optional)

Number

numConfirmations Number of confirmation on the blockchain (default value is 0)

    addresses(optional)

String[]

Addresses from where to get the assetId data (default value is null)

Examples
TitleTypeContent
Example usage: curl curl -X POST -i http://localhost:8081/ -H "Content-Type:application/json" --data '{ jsonrpc: "2.0", // mandatory method: "coloredCoins.getAssetData", // mandatory id: "1", // mandatory if response is needed params: {addresses:["n3TjZPvivsP5xHgRS5zbs83vcYcqDzC8J4","miatv9LDBTe6YwT9begBxPhdfA5tBU9jJi"]} }'
Success
FieldTypeDescription
jsonrpc

String

jsonrpc version

id

String

request id

result

String

Base58 addres

    assetId

String

Asset ID

    assetAmount

Number

Amount of assets

    assetTotalAmount

Number

Total amount of assets ever issued

    assetData

JSON[]

Asset data object array

        address

String

Asset Address

        amount

Number

Asset amount

        utxo

String

Asset UTXO

        metadata

JSON

Asset data object

            divisibility

Number

How divisible is the asset

            version

String

Version of protocol as string

            totalSupply

Number

Total amount of the asset that was issued

            numOfHolders

Number

Number of addresses that have any amount of the asset

            numOfTransactions

Number

Number of transactions that the asset was passed in

            numOfIssuance

Number

Number of times an amount of the asset was issued

            firstAppearsInBlock

Number

First time this asset appeared in the blockchain (first issue)

            metadataOfIssuance

Object

Metadata of the issuance

                assetId

String

Asset Id

                assetName

String

Asset Name

                assetGenesis

String

Genesis transaction where the asset was created (in case of re issue)

                issuer

String

Name of the issuer

                description

String

Description of the asset

                urls

Object[]

Array of URL type objects

                    name

String

Name of the url

                    url

String

The url

                    mimeType

String

Mime type of the data in the url

                    dataHash

String

If needed hash of the data that in the url (for proof reasons)

                userData

JSON

Any arbitrary json data that issuer has entered

            rulesOfIssuance

Object

Object for the rules of the issuance

                version

Number

Version of the rule system

                fees

Object

                    items

Object[]

Array of fee type items

                        address

String

Address to send the fee

                        assetId

String

Asset id to send fee (btc if none asset)

                        value

Number

Value to send for the fee (in satoshi or amount)

                    locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

                expiration

Object

Expiration object used to loan an asset, when asset expires it moves back to last output

                    validUntil

Number

When the asset is consider expired

                    locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

                minters

Object[]

Array of minter objects, (addresses that can issue the asset)

                    address

String

Address of the minter

                    locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type (if the minter can add minters)

                holders

Object[]

Array of holder type objects, they specify in what addresses the asset is considered valid

                    address

String

Address where the asset is considered valid

                    locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

            metadatOfUtxo

Object

Metadata of the specific utxo from the transaction

                assetId

String

Asset Id

                assetName

String

Asset Name

                assetGenesis

String

Genesis transaction where the asset was created (in case of re issue)

                issuer

String

Name of the issuer

                description

String

description of the asset

                urls

Object[]

Array of URL type objects

                    name

String

Name of the url

                    url

String

The url

                    mimeType

String

Mime type of the data in the url

                    dataHash

String

If needed hash of the data that in the url (for proof reasons)

                userData

JSON

Any arbitrary json data that the pervious owner of the output has entered

            rulesofUtxo

Object

Object for the rules of the asset

                version

Number

Version of the rule system

                fees

Object

                    items

Object[]

Array of fee type items

                        address

String

Address to send the fee

                        assetId

String

Asset id to send fee (btc if none asset)

                        value

Number

Value to send for the fee (in satoshi or amount)

                    locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

                expiration

Object

Expiration object used to loan an asset, when asset expires it moves back to last output

                    validUntil

Number

When the asset is consider expired

                    locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

                minters

Object[]

Array of minter objects, (addresses that can issue the asset)

                    address

String

Address of the minter

                    locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type (if the minter can add minters)

                holders

Object[]

Array of holder type objects, they specify in what addresses the asset is considered valid

                    address

String

Address where the asset is considered valid

                    locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

Get Asset Data

var request = require('request');

var assetId = 'LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt'
var addresses = ['mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW','mhTVVgEn9WJHEQaTvURhdGc8yqd9tTiyqu']

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var params = {
    assetId: assetId,
    addresses: addresses,
    numConfirmations: 0
}

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "coloredCoins.getAssetData",
// mandatory id: "1", // mandatory if response is needed params: params // quary parameters } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(JSON.stringify(body)) });

Response

{
    jsonrpc: '2.0',
    id: '1',
    result: { 
        assetId: 'LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt',
        assetAmount: 100,
        assetTotalAmount: 100,
        assetData: [ [Object], [Object], [Object] ] 
    } 
}

Get Asset Data

var request = require('request');

var assetId = 'LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt'
var addresses = ['mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW','mhTVVgEn9WJHEQaTvURhdGc8yqd9tTiyqu']

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var params = {
    assetId: assetId,
    addresses: addresses,
    numConfirmations: 0
}

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "coloredCoins.getAssetData",
// mandatory id: "1", // mandatory if response is needed params: params // quary parameters } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(JSON.stringify(body)) });

Response

{
    jsonrpc: '2.0',
    id: '1',
    result: { 
        assetId: 'LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt',
        assetAmount: 100,
        assetTotalAmount: 100,
        assetData: [ [Object], [Object], [Object] ] 
    } 
}

Get Asset Data

var request = require('request');

var assetId = 'LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt'
var addresses = ['mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW','mhTVVgEn9WJHEQaTvURhdGc8yqd9tTiyqu']

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var params = {
    assetId: assetId,
    addresses: addresses,
    numConfirmations: 0
}

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "coloredCoins.getAssetData",
// mandatory id: "1", // mandatory if response is needed params: params // quary parameters } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(JSON.stringify(body)) });

Response

{
    jsonrpc: '2.0',
    id: '1',
    result: { 
        assetId: 'LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt',
        assetAmount: 100,
        assetTotalAmount: 100,
        assetData: [ [Object], [Object], [Object] ] 
    } 
}

Get Asset Data

var request = require('request');

var assetId = 'LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt'
var addresses = ['mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW','mhTVVgEn9WJHEQaTvURhdGc8yqd9tTiyqu']

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var params = {
    assetId: assetId,
    addresses: addresses,
    numConfirmations: 0
}

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "coloredCoins.getAssetData",
// mandatory id: "1", // mandatory if response is needed params: params // quary parameters } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(JSON.stringify(body)) });

Response

{
    jsonrpc: '2.0',
    id: '1',
    result: { 
        assetId: 'LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt',
        assetAmount: 100,
        assetTotalAmount: 100,
        assetData: [ [Object], [Object], [Object] ] 
    } 
}

Get Address Info

addressinfo API Documentation

TITLERequest to get asset information for the address

VERSION0.1.0

URL/

TYPE[POST]

Description

This API call is used to get all the assets for the address, this information is per utxo owned by the address, also retrives uncolored utxos

Parameters
FieldTypeDescription
jsonrpc

String

jsonrpc version (must be exactly "2.0")

method

String

'getAddressInfo'

id

String

request id, the server's response id will match this id

params

JSON

asset object

    address

String

Base58 address

Examples
TitleTypeContent
Example usage: curl curl -X POST -i http://localhost:8081/ -H "Content-Type:application/json" --data '{ jsonrpc: "2.0", // mandatory method: "coloredCoins.getAddressInfo", // mandatory id: "1", // mandatory if response is needed params: {address:"n3TjZPvivsP5xHgRS5zbs83vcYcqDzC8J4"} }'
Success
FieldTypeDescription
jsonrpc

String

jsonrpc version

id

String

request id

result

String

Base58 addres

    address

String

Base58 address

    utxos

Object[]

Arry of ccUtxo items

        scriptPubKey

Object

ScriptPubKey type object

            asm

String

Asm for the output

            hex

String

Hex for the output

            type

String

Bitcoin transaction type

            reqSigs

Number

Number of required signatures to redeem

            addresses

String[]

Addresses that can redeem

    assets

Object[]

Array of assetInfo type objects

        amount

Number

Amount of the asset in the utxo

        assetId

String

Asset id

        issueTxid

String

Txid that links this utxo to is genises issuance

        divisibility

Number

How divisible the asset is

        lockStatus

Boolean

Was the issuance locked

Get Address Info

var request = require('request');

var assetId = 'LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt'
var address = 'mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW'

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var params = {
    address: address
}

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "coloredCoins.getAddressInfo",
// mandatory id: "1", // mandatory if response is needed params: params // quary parameters } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(JSON.stringify(body)) });

Response

{
  "jsonrpc":"2.0",
  "id":"1",
  "result": {
    "address":"mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW",
    "utxos": [{
      "index":3,
      "txid":"da924abe8b97564df4cb711e41bf619aa02f7b8456172d73ca7a713b0c63b88e",
      "blocktime":1453728644000,
      "blockheight":652897,
      "value":716,
      "used":false,
      "scriptPubKey": {
        "asm":"OP_DUP OP_HASH160 0163a335af7b06bf036af48072ad0c7ed4e659c9 OP_EQUALVERIFY OP_CHECKSIG",
        "hex":"76a9140163a335af7b06bf036af48072ad0c7ed4e659c988ac",
        "reqSigs":1,
        "type":"pubkeyhash",
        "addresses":["mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW"]},
        "assets":[]
      },{
        "index":3,
        "txid":"7bfa9d6ea356daa79f87ae85ebeaed72ef08ffe61295b39cb4414461e34fb207",
        "blocktime":1453731118000,
        "blockheight":652916,
        "value":2032,
        "used":false,
        "scriptPubKey": {
        "asm":"OP_DUP OP_HASH160 0163a335af7b06bf036af48072ad0c7ed4e659c9 OP_EQUALVERIFY OP_CHECKSIG",
        "hex":"76a9140163a335af7b06bf036af48072ad0c7ed4e659c988ac",
        "reqSigs":1,
        "type":"pubkeyhash",
        "addresses":["mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW"]
      },
      "assets": [{
        "assetId":"LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt",
        "amount":80,
        "issueTxid":"da924abe8b97564df4cb711e41bf619aa02f7b8456172d73ca7a713b0c63b88e",
        "divisibility":0,
       "lockStatus":null
      }]
    }]
  }
}

Get Address Info

var request = require('request');

var assetId = 'LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt'
var address = 'mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW'

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var params = {
    address: address
}

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "coloredCoins.getAddressInfo",
// mandatory id: "1", // mandatory if response is needed params: params // quary parameters } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(JSON.stringify(body)) });

Response

{
  "jsonrpc":"2.0",
  "id":"1",
  "result": {
    "address":"mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW",
    "utxos": [{
      "index":3,
      "txid":"da924abe8b97564df4cb711e41bf619aa02f7b8456172d73ca7a713b0c63b88e",
      "blocktime":1453728644000,
      "blockheight":652897,
      "value":716,
      "used":false,
      "scriptPubKey": {
        "asm":"OP_DUP OP_HASH160 0163a335af7b06bf036af48072ad0c7ed4e659c9 OP_EQUALVERIFY OP_CHECKSIG",
        "hex":"76a9140163a335af7b06bf036af48072ad0c7ed4e659c988ac",
        "reqSigs":1,
        "type":"pubkeyhash",
        "addresses":["mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW"]},
        "assets":[]
      },{
        "index":3,
        "txid":"7bfa9d6ea356daa79f87ae85ebeaed72ef08ffe61295b39cb4414461e34fb207",
        "blocktime":1453731118000,
        "blockheight":652916,
        "value":2032,
        "used":false,
        "scriptPubKey": {
        "asm":"OP_DUP OP_HASH160 0163a335af7b06bf036af48072ad0c7ed4e659c9 OP_EQUALVERIFY OP_CHECKSIG",
        "hex":"76a9140163a335af7b06bf036af48072ad0c7ed4e659c988ac",
        "reqSigs":1,
        "type":"pubkeyhash",
        "addresses":["mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW"]
      },
      "assets": [{
        "assetId":"LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt",
        "amount":80,
        "issueTxid":"da924abe8b97564df4cb711e41bf619aa02f7b8456172d73ca7a713b0c63b88e",
        "divisibility":0,
       "lockStatus":null
      }]
    }]
  }
}

Get Address Info

var request = require('request');

var assetId = 'LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt'
var address = 'mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW'

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var params = {
    address: address
}

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "coloredCoins.getAddressInfo",
// mandatory id: "1", // mandatory if response is needed params: params // quary parameters } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(JSON.stringify(body)) });

Response

{
  "jsonrpc":"2.0",
  "id":"1",
  "result": {
    "address":"mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW",
    "utxos": [{
      "index":3,
      "txid":"da924abe8b97564df4cb711e41bf619aa02f7b8456172d73ca7a713b0c63b88e",
      "blocktime":1453728644000,
      "blockheight":652897,
      "value":716,
      "used":false,
      "scriptPubKey": {
        "asm":"OP_DUP OP_HASH160 0163a335af7b06bf036af48072ad0c7ed4e659c9 OP_EQUALVERIFY OP_CHECKSIG",
        "hex":"76a9140163a335af7b06bf036af48072ad0c7ed4e659c988ac",
        "reqSigs":1,
        "type":"pubkeyhash",
        "addresses":["mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW"]},
        "assets":[]
      },{
        "index":3,
        "txid":"7bfa9d6ea356daa79f87ae85ebeaed72ef08ffe61295b39cb4414461e34fb207",
        "blocktime":1453731118000,
        "blockheight":652916,
        "value":2032,
        "used":false,
        "scriptPubKey": {
        "asm":"OP_DUP OP_HASH160 0163a335af7b06bf036af48072ad0c7ed4e659c9 OP_EQUALVERIFY OP_CHECKSIG",
        "hex":"76a9140163a335af7b06bf036af48072ad0c7ed4e659c988ac",
        "reqSigs":1,
        "type":"pubkeyhash",
        "addresses":["mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW"]
      },
      "assets": [{
        "assetId":"LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt",
        "amount":80,
        "issueTxid":"da924abe8b97564df4cb711e41bf619aa02f7b8456172d73ca7a713b0c63b88e",
        "divisibility":0,
       "lockStatus":null
      }]
    }]
  }
}

Get Address Info

var request = require('request');

var assetId = 'LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt'
var address = 'mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW'

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var params = {
    address: address
}

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "coloredCoins.getAddressInfo",
// mandatory id: "1", // mandatory if response is needed params: params // quary parameters } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(JSON.stringify(body)) });

Response

{
  "jsonrpc":"2.0",
  "id":"1",
  "result": {
    "address":"mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW",
    "utxos": [{
      "index":3,
      "txid":"da924abe8b97564df4cb711e41bf619aa02f7b8456172d73ca7a713b0c63b88e",
      "blocktime":1453728644000,
      "blockheight":652897,
      "value":716,
      "used":false,
      "scriptPubKey": {
        "asm":"OP_DUP OP_HASH160 0163a335af7b06bf036af48072ad0c7ed4e659c9 OP_EQUALVERIFY OP_CHECKSIG",
        "hex":"76a9140163a335af7b06bf036af48072ad0c7ed4e659c988ac",
        "reqSigs":1,
        "type":"pubkeyhash",
        "addresses":["mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW"]},
        "assets":[]
      },{
        "index":3,
        "txid":"7bfa9d6ea356daa79f87ae85ebeaed72ef08ffe61295b39cb4414461e34fb207",
        "blocktime":1453731118000,
        "blockheight":652916,
        "value":2032,
        "used":false,
        "scriptPubKey": {
        "asm":"OP_DUP OP_HASH160 0163a335af7b06bf036af48072ad0c7ed4e659c9 OP_EQUALVERIFY OP_CHECKSIG",
        "hex":"76a9140163a335af7b06bf036af48072ad0c7ed4e659c988ac",
        "reqSigs":1,
        "type":"pubkeyhash",
        "addresses":["mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW"]
      },
      "assets": [{
        "assetId":"LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt",
        "amount":80,
        "issueTxid":"da924abe8b97564df4cb711e41bf619aa02f7b8456172d73ca7a713b0c63b88e",
        "divisibility":0,
       "lockStatus":null
      }]
    }]
  }
}

Get Asset Holders

stakeholders API Documentation

TITLERequest asset holders

VERSION0.1.0

URL/

TYPE[POST]

Description

This API call is used to get all the addresses that contain any value of the specified asset

Parameters
FieldTypeDescription
jsonrpc

String

jsonrpc version (must be exactly "2.0")

method

String

'getStakeHolders'

id

String

request id, the server's response id will match this id

params

JSON

asset object

    assetId

String

Asset unique ID

    numConfirmations

Number

Number of confiramtions for the utxos to return

Examples
TitleTypeContent
Example usage: curl curl -X POST -i http://localhost:8081/ -H "Content-Type:application/json" --data '{ jsonrpc: "2.0", // mandatory method: "coloredCoins.getStakeHolders", // mandatory id: "1", // mandatory if response is needed params: {assetId:"LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt",numConfirmations:0} }'
Success
FieldTypeDescription
jsonrpc

String

jsonrpc version

id

String

request id

result

String

Base58 addres

    holders

Object[]

Array of holder objects.

        address

Object[]

Address that has holding of the asset

        amount

Object[]

Amount of the asset in the address

Get Stake Holders

var request = require('request');

var assetId = 'LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt'
var numConfirmations = 0

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var params = {
    assetId: assetId,
    numConfirmations: numConfirmations
}

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "coloredCoins.getStakeHolders",
// mandatory id: "1", // mandatory if response is needed params: params // quary parameters } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(JSON.stringify(body)) });

Response

{
  "jsonrpc":"2.0",
  "id":"1",
  "result": {
    "assetId":"LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt",
    "holders": [{
      "address":"mhTVVgEn9WJHEQaTvURhdGc8yqd9tTiyqu",
      "amount":20
    },{
      "address":"mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW",
      "amount":80
    }],
    "divisibility":0,
    "lockStatus":null,
    "someUtxo":"b905a0d835393245cef9901f891fa1058e33c2ac44fb01b437055aeeab401c55:1"
}}

Get Stake Holders

var request = require('request');

var assetId = 'LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt'
var numConfirmations = 0

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var params = {
    assetId: assetId,
    numConfirmations: numConfirmations
}

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "coloredCoins.getStakeHolders",
// mandatory id: "1", // mandatory if response is needed params: params // quary parameters } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(JSON.stringify(body)) });

Response

{
  "jsonrpc":"2.0",
  "id":"1",
  "result": {
    "assetId":"LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt",
    "holders": [{
      "address":"mhTVVgEn9WJHEQaTvURhdGc8yqd9tTiyqu",
      "amount":20
    },{
      "address":"mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW",
      "amount":80
    }],
    "divisibility":0,
    "lockStatus":null,
    "someUtxo":"b905a0d835393245cef9901f891fa1058e33c2ac44fb01b437055aeeab401c55:1"
}}

Get Stake Holders

var request = require('request');

var assetId = 'LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt'
var numConfirmations = 0

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var params = {
    assetId: assetId,
    numConfirmations: numConfirmations
}

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "coloredCoins.getStakeHolders",
// mandatory id: "1", // mandatory if response is needed params: params // quary parameters } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(JSON.stringify(body)) });

Response

{
  "jsonrpc":"2.0",
  "id":"1",
  "result": {
    "assetId":"LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt",
    "holders": [{
      "address":"mhTVVgEn9WJHEQaTvURhdGc8yqd9tTiyqu",
      "amount":20
    },{
      "address":"mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW",
      "amount":80
    }],
    "divisibility":0,
    "lockStatus":null,
    "someUtxo":"b905a0d835393245cef9901f891fa1058e33c2ac44fb01b437055aeeab401c55:1"
}}

Get Stake Holders

var request = require('request');

var assetId = 'LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt'
var numConfirmations = 0

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var params = {
    assetId: assetId,
    numConfirmations: numConfirmations
}

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "coloredCoins.getStakeHolders",
// mandatory id: "1", // mandatory if response is needed params: params // quary parameters } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(JSON.stringify(body)) });

Response

{
  "jsonrpc":"2.0",
  "id":"1",
  "result": {
    "assetId":"LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt",
    "holders": [{
      "address":"mhTVVgEn9WJHEQaTvURhdGc8yqd9tTiyqu",
      "amount":20
    },{
      "address":"mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW",
      "amount":80
    }],
    "divisibility":0,
    "lockStatus":null,
    "someUtxo":"b905a0d835393245cef9901f891fa1058e33c2ac44fb01b437055aeeab401c55:1"
}}

Get Asset Metadata

assetmetadata API Documentation

TITLERequest asset metadata and utxo metadata

VERSION0.1.0

URL/

TYPE[POST]

Description

This API call is used to get the metadata of the issuance of an asset, if a specific utxo is provided it will also get the metadata for that specific utxo which was set by the previous owner of that asset on the blockchain

Parameters
FieldTypeDescription
jsonrpc

String

jsonrpc version (must be exactly "2.0")

method

String

'getAssetMetadata'

id

String

request id, the server's response id will match this id

params

JSON

asset object

    assetId

String

Asset unique ID.

    utxo(optional)

String

Unspent in : format

Examples
TitleTypeContent
Example usage: curl curl -X POST -i http://localhost:8081/ -H "Content-Type:application/json" --data '{ jsonrpc: "2.0", // mandatory method: "getAssetMetadata", // mandatory id: "1", // mandatory if response is needed params: { assetId:"LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt", utxo:"b905a0d835393245cef9901f891fa1058e33c2ac44fb01b437055aeeab401c55:1" } }'
Success
FieldTypeDescription
jsonrpc

String

jsonrpc version

id

String

request id

result

String

Base58 addres

    divisibility

Number

How divisible is the asset

    version

String

Version of protocol as string

    totalSupply

Number

Total amount of the asset that was issued

    numOfHolders

Number

Number of addresses that have any amount of the asset

    numOfTransactions

Number

Number of transactions that the asset was passed in

    numOfIssuance

Number

Number of times an amount of the asset was issued

    firstAppearsInBlock

Number

First time this asset appeared in the blockchain (first issue)

    metadataOfIssuance

Object

Metadata of the issuance

        assetId

String

Asset Id

        assetName

String

Asset Name

        assetGenesis

String

Genesis transaction where the asset was created (in case of re issue)

        issuer

String

Name of the issuer

        description

String

Description of the asset

        urls

Object[]

Array of URL type objects

            name

String

Name of the url

            url

String

The url

            mimeType

String

Mime type of the data in the url

            dataHash

String

If needed hash of the data that in the url (for proof reasons)

        userData

JSON

Any arbitrary json data that issuer has entered

    rulesOfIssuance

Object

Object for the rules of the issuance

        version

Number

Version of the rule system

        fees

Object

            items

Object[]

Array of fee type items

                address

String

Address to send the fee

                assetId

String

Asset id to send fee (btc if none asset)

                value

Number

Value to send for the fee (in satoshi or amount)

            locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

        expiration

Object

Expiration object used to loan an asset, when asset expires it moves back to last output

            validUntil

Number

When the asset is consider expired

            locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

        minters

Object[]

Array of minter objects, (addresses that can issue the asset)

            address

String

Address of the minter

            locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type (if the minter can add minters)

        holders

Object[]

Array of holder type objects, they specify in what addresses the asset is considered valid

            address

String

Address where the asset is considered valid

            locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

    metadatOfUtxo

Object

Metadata of the specific utxo from the transaction

        assetId

String

Asset Id

        assetName

String

Asset Name

        assetGenesis

String

Genesis transaction where the asset was created (in case of re issue)

        issuer

String

Name of the issuer

        description

String

description of the asset

        urls

Object[]

Array of URL type objects

            name

String

Name of the url

            url

String

The url

            mimeType

String

Mime type of the data in the url

            dataHash

String

If needed hash of the data that in the url (for proof reasons)

        userData

JSON

Any arbitrary json data that the pervious owner of the output has entered

    rulesofUtxo

Object

Object for the rules of the asset

        version

Number

Version of the rule system

        fees

Object

            items

Object[]

Array of fee type items

                address

String

Address to send the fee

                assetId

String

Asset id to send fee (btc if none asset)

                value

Number

Value to send for the fee (in satoshi or amount)

            locked

Boolean

Failedthransaction to specify if following transaction of the asset can add to this rule type

        expiration

Object

Expiration object used to loanFeild an asset, when asset expires it moves back to last output

            validUntil

Number

When the asset is consider expired

            locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

        minters

Object[]

Array of minter objects, (addresses that can issue the asset)

            address

String

Address of the minter

            locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type (if the minter can add minters)

        holders

Object[]

Array of holder type objects, they specify in what addresses the asset is considered valid

            address

String

Address where the asset is considered valid

            locked

Boolean

Failed to specify if following transaction of the asset can add to this rule type

Get Asset Metadata

var request = require('request');

var assetId = 'LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt'
var utxo = 'b905a0d835393245cef9901f891fa1058e33c2ac44fb01b437055aeeab401c55:1'

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var params = {
    assetId: assetId,
    utxo: utxo
}

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "getAssetMetadata",
// mandatory id: "1", // mandatory if response is needed params: params // quary parameters } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); //console.log(JSON.stringify(body)) console.log(body) });

Response

{ 
    jsonrpc: '2.0',
    id: '1',
    result: { 
        assetId: 'LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt',
        divisibility: 0,
        lockStatus: null,
        someUtxo: 'b905a0d835393245cef9901f891fa1058e33c2ac44fb01b437055aeeab401c55:1',
        totalSupply: 100,
        numOfHolders: 2,
        numOfTransfers: 2,
        numOfIssuance: 1,
        firstBlock: 652897,
        issuanceTxid: 'da924abe8b97564df4cb711e41bf619aa02f7b8456172d73ca7a713b0c63b88e',
        issueAddress: 'mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW',
        metadataOfIssuence: { data: [Object] },
        sha2Issue: '038ad7eaf38215d649b8adc9e5e749cab52f70820372d974f7d4f5ac076b79c747',
        metadataOfUtxo: { data: [Object] },
        sha2Utxo: '03ff7e5db2203b4cf330203b4255269b8c88d89802757fdccf2dd4b57a91aebdd6' 
    } 
}

Get Asset Metadata

var request = require('request');

var assetId = 'LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt'
var utxo = 'b905a0d835393245cef9901f891fa1058e33c2ac44fb01b437055aeeab401c55:1'

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var params = {
    assetId: assetId,
    utxo: utxo
}

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "getAssetMetadata",
// mandatory id: "1", // mandatory if response is needed params: params // quary parameters } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); //console.log(JSON.stringify(body)) console.log(body) });

Response

{ 
    jsonrpc: '2.0',
    id: '1',
    result: { 
        assetId: 'LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt',
        divisibility: 0,
        lockStatus: null,
        someUtxo: 'b905a0d835393245cef9901f891fa1058e33c2ac44fb01b437055aeeab401c55:1',
        totalSupply: 100,
        numOfHolders: 2,
        numOfTransfers: 2,
        numOfIssuance: 1,
        firstBlock: 652897,
        issuanceTxid: 'da924abe8b97564df4cb711e41bf619aa02f7b8456172d73ca7a713b0c63b88e',
        issueAddress: 'mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW',
        metadataOfIssuence: { data: [Object] },
        sha2Issue: '038ad7eaf38215d649b8adc9e5e749cab52f70820372d974f7d4f5ac076b79c747',
        metadataOfUtxo: { data: [Object] },
        sha2Utxo: '03ff7e5db2203b4cf330203b4255269b8c88d89802757fdccf2dd4b57a91aebdd6' 
    } 
}

Get Asset Metadata

var request = require('request');

var assetId = 'LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt'
var utxo = 'b905a0d835393245cef9901f891fa1058e33c2ac44fb01b437055aeeab401c55:1'

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var params = {
    assetId: assetId,
    utxo: utxo
}

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "getAssetMetadata",
// mandatory id: "1", // mandatory if response is needed params: params // quary parameters } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); //console.log(JSON.stringify(body)) console.log(body) });

Response

{ 
    jsonrpc: '2.0',
    id: '1',
    result: { 
        assetId: 'LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt',
        divisibility: 0,
        lockStatus: null,
        someUtxo: 'b905a0d835393245cef9901f891fa1058e33c2ac44fb01b437055aeeab401c55:1',
        totalSupply: 100,
        numOfHolders: 2,
        numOfTransfers: 2,
        numOfIssuance: 1,
        firstBlock: 652897,
        issuanceTxid: 'da924abe8b97564df4cb711e41bf619aa02f7b8456172d73ca7a713b0c63b88e',
        issueAddress: 'mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW',
        metadataOfIssuence: { data: [Object] },
        sha2Issue: '038ad7eaf38215d649b8adc9e5e749cab52f70820372d974f7d4f5ac076b79c747',
        metadataOfUtxo: { data: [Object] },
        sha2Utxo: '03ff7e5db2203b4cf330203b4255269b8c88d89802757fdccf2dd4b57a91aebdd6' 
    } 
}

Get Asset Metadata

var request = require('request');

var assetId = 'LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt'
var utxo = 'b905a0d835393245cef9901f891fa1058e33c2ac44fb01b437055aeeab401c55:1'

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var params = {
    assetId: assetId,
    utxo: utxo
}

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "getAssetMetadata",
// mandatory id: "1", // mandatory if response is needed params: params // quary parameters } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); //console.log(JSON.stringify(body)) console.log(body) });

Response

{ 
    jsonrpc: '2.0',
    id: '1',
    result: { 
        assetId: 'LJMJ21ySv9LbG88eSYcAkvPoNy3zCj4auDYMt',
        divisibility: 0,
        lockStatus: null,
        someUtxo: 'b905a0d835393245cef9901f891fa1058e33c2ac44fb01b437055aeeab401c55:1',
        totalSupply: 100,
        numOfHolders: 2,
        numOfTransfers: 2,
        numOfIssuance: 1,
        firstBlock: 652897,
        issuanceTxid: 'da924abe8b97564df4cb711e41bf619aa02f7b8456172d73ca7a713b0c63b88e',
        issueAddress: 'mfeJLBb4BBGjQ2rSyALMA3tsXM4jYgtGXW',
        metadataOfIssuence: { data: [Object] },
        sha2Issue: '038ad7eaf38215d649b8adc9e5e749cab52f70820372d974f7d4f5ac076b79c747',
        metadataOfUtxo: { data: [Object] },
        sha2Utxo: '03ff7e5db2203b4cf330203b4255269b8c88d89802757fdccf2dd4b57a91aebdd6' 
    } 
}

Get Assets

assets API Documentation

TITLERequest to get all wallet assets

VERSION0.1.0

URL/

TYPE[POST]

Description

This API call is used to get all assets held by addresses associated with the user wallet

Parameters
FieldTypeDescription
jsonrpc

String

jsonrpc version (must be exactly "2.0")

method

String

'getAssets'

id

String

request id, the server's response id will match this id

Examples
TitleTypeContent
Example usage: curl curl -X POST -i http://localhost:8081/ -H "Content-Type:application/json" --data '{ jsonrpc: "2.0", // mandatory method: "coloredCoins.getAddressInfo", // mandatory id: "1" // mandatory if response is needed }'
Success
FieldTypeDescription
jsonrpc

String

jsonrpc version

id

String

request id

result

String

Base58 addres

address

String

Base58 address

txid

String

Transaction id

index

Number

Transaction index of the utxo

assetId

String

Asset id

amount

Number

Asset amount

issueTxid

String

Issuance transaction id

divisibility

Number

Asset divisibility

lockStatus

Boolean

Lock status

aggregationPolicy

String

Aggregation policy (aggregatable or dispersed)

assetIndex

Number

Asset index in the utxo

Get Address Info

var request = require('request');

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "getAssets",
// mandatory id: "1" // mandatory if response is needed } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(JSON.stringify(body)) });

Response

{
  "jsonrpc":"2.0",
  "id":"1",
  "result": [{ 
      address: 'mwfCjZu13rQAVmqfu97RkE4n6Xwgr7jvEK',
      txid: 'afe6a1d84ee508c4d9c8f7f511fb5701a1f758aff3a883416b6d74e184f8cb3d',
      index: 0,
      assetId: 'Ua4U2xUmTKgbu3WSb67g5NLSWBHL7QWdQTNH2b',
      amount: 1,
      issueTxid: 'afe6a1d84ee508c4d9c8f7f511fb5701a1f758aff3a883416b6d74e184f8cb3d',
      divisibility: 0,
      lockStatus: false,
      aggregationPolicy: 'aggregatable',
      assetIndex: 0 
  }]
}

Get Address Info

var request = require('request');

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "getAssets",
// mandatory id: "1" // mandatory if response is needed } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(JSON.stringify(body)) });

Response

{
  "jsonrpc":"2.0",
  "id":"1",
  "result": [{ 
      address: 'mwfCjZu13rQAVmqfu97RkE4n6Xwgr7jvEK',
      txid: 'afe6a1d84ee508c4d9c8f7f511fb5701a1f758aff3a883416b6d74e184f8cb3d',
      index: 0,
      assetId: 'Ua4U2xUmTKgbu3WSb67g5NLSWBHL7QWdQTNH2b',
      amount: 1,
      issueTxid: 'afe6a1d84ee508c4d9c8f7f511fb5701a1f758aff3a883416b6d74e184f8cb3d',
      divisibility: 0,
      lockStatus: false,
      aggregationPolicy: 'aggregatable',
      assetIndex: 0 
  }]
}

Get Address Info

var request = require('request');

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "getAssets",
// mandatory id: "1" // mandatory if response is needed } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(JSON.stringify(body)) });

Response

{
  "jsonrpc":"2.0",
  "id":"1",
  "result": [{ 
      address: 'mwfCjZu13rQAVmqfu97RkE4n6Xwgr7jvEK',
      txid: 'afe6a1d84ee508c4d9c8f7f511fb5701a1f758aff3a883416b6d74e184f8cb3d',
      index: 0,
      assetId: 'Ua4U2xUmTKgbu3WSb67g5NLSWBHL7QWdQTNH2b',
      amount: 1,
      issueTxid: 'afe6a1d84ee508c4d9c8f7f511fb5701a1f758aff3a883416b6d74e184f8cb3d',
      divisibility: 0,
      lockStatus: false,
      aggregationPolicy: 'aggregatable',
      assetIndex: 0 
  }]
}

Get Address Info

var request = require('request');

function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
        url: 'http://localhost:8081/'+api_endpoint,
        headers: {
            'Content-Type': 'application/json', 
            'Accept': 'application/json',
            'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
        },
        body: JSON.stringify(json_data)
    }, 
    function (error, response, body) {
        if (error) {
            return callback(error);
        }
        if (typeof body === 'string') {
            body = JSON.parse(body);
        }

        return callback(null, body);
    });
};

var json_data = {
    jsonrpc: "2.0", // mandatory
    
method: "getAssets",
// mandatory id: "1" // mandatory if response is needed } postToApi('', json_data, function(err, body){ if (err) console.log('error: ',err); console.log(JSON.stringify(body)) });

Response

{
  "jsonrpc":"2.0",
  "id":"1",
  "result": [{ 
      address: 'mwfCjZu13rQAVmqfu97RkE4n6Xwgr7jvEK',
      txid: 'afe6a1d84ee508c4d9c8f7f511fb5701a1f758aff3a883416b6d74e184f8cb3d',
      index: 0,
      assetId: 'Ua4U2xUmTKgbu3WSb67g5NLSWBHL7QWdQTNH2b',
      amount: 1,
      issueTxid: 'afe6a1d84ee508c4d9c8f7f511fb5701a1f758aff3a883416b6d74e184f8cb3d',
      divisibility: 0,
      lockStatus: false,
      aggregationPolicy: 'aggregatable',
      assetIndex: 0 
  }]
}

Colu API - Getting Started

In this getting started guide we will walk you through the two core examples of the Colu API, issuing a new asset and transferring an existing asset.

To use Colu API you first need to deploy, host and run colu-nodejs server.
In the first section we will deploy and run the server on your own localhost.
You can deploy the server at a remote host or at any cloud environment.
The server uses JSON-RPC 2.0 protocol.

The examples given in this guide are written in javascript using the popular libraries node js and bitcoinjs

First, we will walk you through the necessary steps needed to setup your machine in order to follow the rest of the guide.

Installing Node JS

Colu's SDK is currently available only for node js (more languages coming soon).
For completeness, this section walks you through the installation process of node js on Linux (Ubuntu).

Start with downloading the package by launching a terminal window and typing:

> curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -

Install node js by typing

> sudo apt-get install -y nodejs

Verify your node js installation

Open a text editor and save the following in a file called example.js

var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Colu\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');

Now launch a terminal window and type

> node example.js

Launch a web browser and visit localhost:1337. You should see the text "Colu"

 

 

 

 

Install & Run Colu Server

First we need to deploy, host and run the server that will run Colu API.
We will deploy colu-nodejs server on localhost by following those steps:

Each server run represents a wallet that holds a private key for asset management.

1. Open a command prompt (cmd.exe)

2. Write at the command prompt:

npm i -g colu

Wait for 'colu' module installation process to finish.

3. Now, we need to configure the system environment variables.

It’s not mandatory to set the system environment variables.
The server is launched by default on localhost:80

Lets configure the system environment variables, for Mac, Linux and for Windows:

For Mac & Linux:

Write at the command prompt:

export COLU_SDK_RPC_SERVER_HTTP_PORT=8081

For Windows:

a. Right click on 'This PC' (or 'My Computer' at Win7)
b. Click on 'Properties'
c. Click on 'Addvanced System Settings' (on the left upper area)
d. On 'Advance' tab, click on 'Environment Variables' (bottom area)
e. On 'System Variables' (bottom), click on 'New...'
f. Add 'COLU_SDK_RPC_SERVER_HTTP_PORT' to the 'Variable name', and '8081' to 'Variable value'

The port number doesn’t have to be 8081.
You can configure the server port to any number you choose.

Here are all relevant system environment variables:

COLU_SDK_NETWORK // 'testnet' or 'mainnet' (default = 'mainnet')
COLU_SDK_COLU_HOST // Colu engine API address
COLU_SDK_API_KEY // Your API key (valid for 'mainnet' only)
COLU_SDK_PRIVATE_SEED // Private seed for Base58 private key (private seed | private seed WIF)
COLU_SDK_PRIVATE_SEED_WIF // Base58 private key WIF (private seed | private seed WIF)
COLU_SDK_REDIS_PORT // Redis port
COLU_SDK_REDIS_HOST // Redis host
COLU_SDK_RPC_SERVER_HTTP_PORT // HTTP port (default = 80)
COLU_SDK_RPC_SERVER_HTTPS_PORT // HTTPS port (default = 443)
COLU_SDK_RPC_SERVER_HOST // Server host
COLU_SDK_RPC_USE_SSL // Use SSL and launch HTTPS server (default = false)
COLU_SDK_RPC_PRIVATE_KEY_PATH // SSL private key path (valid only if COLU_SDK_RPC_USE_SSL = true)
COLU_SDK_RPC_CERTIFICATE_PATH // SSL certificate path (valid only if COLU_SDK_RPC_USE_SSL = true)
COLU_SDK_RPC_USE_BASIC_AUTH // Use HTTP basic authentication (default = false)
COLU_SDK_RPC_USER_NAME // User name for HTTP basic authentication (valid only if COLU_SDK_RPC_USE_BASIC_AUTH = true)
COLU_SDK_RPC_PASSWORD // Password for HTTP basic authentication (valid only if COLU_SDK_RPC_USE_BASIC_AUTH = true)
COLU_SDK_RPC_USE_BOTH // Use both HTTP and HTTPS servers (valid only if COLU_SDK_RPC_USE_SSL = true, default = false)

4. Write at the command prompt:

For Mac & Linux:

node $(which colu)

For Windows:

colu

The server is running and ready when you see the following output:

http server started on port 8081

All Colu API call are POST methods.

Now, the server is installed and running.

You can run the same process on a remote or a cloud server.

No we are ready to start using all API methods.

 

 

 

 

Save Private Seed

In order to use the same wallet at every server upload, we need to save the private seed at the System Environment Variable.

First, we need to get the wallet private key.

Lets run the following code:

var request = require('request');

function postToApi(api_endpoint, json_data, callback) {
console.log(api_endpoint+': ', JSON.stringify(json_data));
request.post({
url: 'http://localhost:8081/'+api_endpoint,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
},
body: JSON.stringify(json_data)
},
function (error, response, body) {
if (error) {
return callback(error);
}
if (typeof body === 'string') {
body = JSON.parse(body);
}
return callback(null, body);
});
};

var json_data = {
jsonrpc: "2.0", // mandatory
method: "hdwallet.getPrivateSeed", // mandatory
id: "1" // mandatory if response is needed
}

postToApi('', json_data, function(err, body){

if (err) console.log('error: ',err);

console.log(body)

});

We get the response:

{ 
jsonrpc: '2.0',
id: '1',
result: '4835dd1e97f74f61bbf3579e688eeff36cbfe0cfac4dabccfab0d0db4125b683'
}

The wallet private seed is '4835dd1e97f74f61bbf3579e688eeff36cbfe0cfac4dabccfab0d0db4125b683'.
Now we can save the private seed to the System Environment Variables.

Lets do it for Mac, Linux and for Windows:

For Mac & Linux:

Write at command prompt:

export COLU_SDK_PRIVATE_SEED=4835dd1e97f74f61bbf3579e688eeff36cbfe0cfac4dabccfab0d0db4125b683

For Windows:

a. Right click on 'This PC' (or 'My Computer' at Win7)
b. Click on 'Properties'
c. Click on 'Addvanced System Settings' (on the left upper area)
d. On 'Advance' tab, click on 'Environment Variables' (bottom area)
e. On 'System Variables' (bottom), click on 'New...'
f. Add 'COLU_SDK_PRIVATE_SEED' to the 'Variable name', and '4835dd1e97f74f61bbf3579e688eeff36cbfe0cfac4dabccfab0d0db4125b683' to 'Variable value'

Now we shall use the same wallet on each server upload.

 

 

 

 

Issue Assets

In this section we explain how to use Colu's API to issue a new Asset.

 

 

 

 

Simple Issue

Because all Colu API are POST methods, first lets write the POST function:

var request = require('request');

function postToApi(api_endpoint, json_data, callback) {
console.log(api_endpoint+': ', JSON.stringify(json_data));
request.post({
url: 'http://localhost:8081/'+api_endpoint,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
},
body: JSON.stringify(json_data)
},
function (error, response, body) {
if (error) {
return callback(error);
}
if (typeof body === 'string') {
body = JSON.parse(body);
}

return callback(null, body);
});
};

We will always use this POST method at the rest of this example.

This time we ask the colu object to issue a new asset with 1 million units. This is done by specifying the number of units using the amount key in a json object:

var asset = {
amount: 1000000
}

We first need to define execution json object:

var json_data = {
jsonrpc: "2.0", // mandatory
method: "issueAsset", // mandatory
id: "1", // mandatory if response is needed
params: asset // quary parameters
}

Now we can issue this asset by invoking the issueAsset method on the colu object with our asset parameter:

postToApi('', json_data, function(err, body){
if (err) console.log('error: ',err);
console.log(JSON.stringify(body))
});

Here is the response:

{ 
jsonrpc: '2.0',
id: '1',
result: { txHex: '010000000181704ea8e573a0a7dbec6e0213d757721f82afc9f91e453b27d2e30c8c4f1ac10000000000ffffffff0358020000000000001976a9147aa6f36ef275974e795f58c207d21a280bbd3af688ac00000000000000000c6a0a4343010526440026441078050000000000001976a9147aa6f36ef275974e795f58c207d21a280bbd3af688ac00000000',
assetId: 'LGDBaMSAkgVJ5aoERUzyYcof6c4ypRArGmpZc',
multisigOutputs: [],
txid: '1ca23e71ca24e4ff16e13009c77c2f67051547a8df1e3e6fc5a9cdb56fcd04ed',
receivingAddresses:
[ { address: 'mrhUjQjcZZxMcmPnrCZZ3BqYHNyVeQXCea',
amount: 1000000 } ],
issueAddress: 'mrhUjQjcZZxMcmPnrCZZ3BqYHNyVeQXCea' } }

The return message tells us that we successfully issued a new asset with id LGDBaMSAkgVJ5aoERUzyYcof6c4ypRArGmpZc in transaction 1ca23e71ca24e4ff16e13009c77c2f67051547a8df1e3e6fc5a9cdb56fcd04ed.
The Asset was issued at address mrhUjQjcZZxMcmPnrCZZ3BqYHNyVeQXCea (which is one of the addresses in our local HD wallet).

Let's confirm that using the colored coins testnet explorer.

First let's look at the asset

ASSET NAME: N/A                           LOCKED ASSET

ISSUANCE
Name Amount utxo
LGDBaMSAkgVJ5aoERUzyYcof6c4ypRArGmpZc 1000000 1ca23e71ca24e4ff16e13009c77c2f67051547a8df1e3e6fc5a9cdb56fcd04ed

HOLDERS
Address Amount
mrhUjQjcZZxMcmPnrCZZ3BqYHNyVeQXCea 1000000

TRANSFER TRANSACTIONS
No Transactions Found

ISSUE TRANSACTIONS
dba9acac2f0afa45aa5da9c37bc283...
Sent 0.00002 Asset Sent 1000000

The explorer confirms that there are 1,000,000 units of our LGDBaMSAkgVJ5aoERUzyYcof6c4ypRArGmpZc asset, all sitting in the issuance address mrhUjQjcZZxMcmPnrCZZ3BqYHNyVeQXCea.

Note that if you look at the issuance transaction you can see that 2000 satoshis were sent to the issuance address and another 1000 paid as transaction fee. Those costs are covered by Colu.

 

 

 

 

Issue with Metadata

Colored Coins assets can include arbitrary amounts of Metadata.

We can embed metadata in the asset at issuance by declaring a metadata key in the asset definition:

var asset = {
amount: 500,
metadata: {
'assetName': 'Mission Impossible 15',
'issuer': 'Fox Theater',
'description': 'Movie ticket to see the New Tom Cruise flick'
}
}

var json_data = {
jsonrpc: "2.0", // mandatory
method: "issueAsset", // mandatory
id: "1", // mandatory if response is needed
params: asset // quary parameters
}

postToApi('', json_data, function(err, body){
if (err) console.log('error: ',err);
console.log(JSON.stringify(body))
});

This example can be thought of as issuing 500 tickets to a movie.

Here is the response

{ 
jsonrpc: '2.0',
id: '1',
result: { txHex: '0100000001f7782f48ce7bf39e349a97bcb06c48702b4e1dd68fbb9f0e786e8fae81e6c02f0000000000ffffffff04ac0200000000000047512103ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff21034976c163e25cfd8ff92c1962c2cbbb8fd60f3cf6a818e0bcac5fcb7e239ef33252ae58020000000000001976a914e57f8df8e3cae90571da07dc97ac781e1c6aa43288ac0000000000000000206a1e4343010261d5d531d0f6c9254f779ce530de02635e0930ac205201205210cc020000000000001976a914e57f8df8e3cae90571da07dc97ac781e1c6aa43288ac00000000',
assetId: 'LEUWnac9Pp7kZYC3W19xtVMVqL8jw6m19RZHu',
multisigOutputs: [],
txid: 'f9fff185dc1df89ffe13cd7e5668a0af2953622176de91232ec1be975c6114c4',
receivingAddresses: [ { address: 'n2SRqdXxbKpZPyVNBCdTM9Y5vHUcLEWVvE', amount: 500 } ],
issueAddress: 'n2SRqdXxbKpZPyVNBCdTM9Y5vHUcLEWVvE' } }

Let's look at the asset

ASSET NAME: Mission Impossible 15         LOCKED ASSET

ISSUANCE
Name Issuer Amount utxo
Mission Impossible 15 Fox Theater 500 f9fff185dc1df89ffe13cd7e5668a0af2953622176de91232ec1be975c6114c4

HOLDERS
Address Amount
n2SRqdXxbKpZPyVNBCdTM9Y5vHUcLEWVvE 500

TRANSFER TRANSACTIONS
No Transactions Found

ISSUE TRANSACTIONS
f9fff185dc1df89ffe13cd7e5668a0...
Sent 0.00002 Asset Sent 500

This time we see the asset name and asset issuer. Please consult the colored coins protocol specification to learn about more general metadata structures that are supported. Later on we will learn how to use the SDK to query an asset and retrieve the full set of metadata.

 

 

 

 

Reissuing an Asset

In this section we will discuss asset re-issuance and it's relation to the concepts of Locked and Unlocked assets.

Note that for all the assets that we issued in the previous sections, the explorer displayed a LOCKED ASSET symbol near the asset name. Locked Assets are asset that are issued once and cannot be re-issued. There can be an unlimited number of locked assets in one Bitcoin address.

Unlocked assets on the other hand are tied to the issuance address in a way that we explore below.

Let's start by issuing an Unlocked asset. We do that by including the reissuable key in the asset definition and setting it to true:

var asset = {
amount: 1000000,
reissueable: true
}

var json_data = {
jsonrpc: "2.0", // mandatory
method: "issueAsset", // mandatory
id: "1", // mandatory if response is needed
params: asset // quary parameters
}

postToApi('', json_data, function(err, body){
if (err) console.log('error: ',err);
console.log(JSON.stringify(body))
});

Here is the response:

{ 
jsonrpc: '2.0',
id: '1',
result: { txHex: '01000000017b58760bcdbe7c4701dc53f546ed1edc4ff6adf5b0ce35e162a56f8bba5aa2440000000000ffffffff0358020000000000001976a9145ed9f47408f7bc2567b8ef7da07c17e7e06f382c88ac00000000000000000c6a0a4343010526440026440078050000000000001976a9145ed9f47408f7bc2567b8ef7da07c17e7e06f382c88ac00000000',
assetId: 'U5haTxTknzcq94czuXQRHa7Nw38BUxnQWAX6w',
multisigOutputs: [],
txid: '72ea2228a6e555228a4e84685932eac1b395bfe512e81ce8bf9f27649be14dff',
receivingAddresses:
[ { address: 'mpAUurhbWXFtczKVPn7iLf7rfcDhMdH6tH',
amount: 1000000 } ],
issueAddress: 'mpAUurhbWXFtczKVPn7iLf7rfcDhMdH6tH' } }

Let's look at this asset in the explorer:

ASSET NAME: N/A                          UNLOCKED ASSET

ISSUANCE
Name Issuer Amount utxo
U5haTxTknzcq94czuXQRHa... 1000000 72ea2228a6e555228a4e84685932eac1b395bfe512e81ce8bf9f27649be14dff

HOLDERS
Address Amount
mpAUurhbWXFtczKVPn7iLf7rfcDhMdH6tH 1000000

TRANSFER TRANSACTIONS
No Transactions Found
ISSUE TRANSACTIONS
72ea2228a6e555228a4e84685932ea...
Sent 0.00002 Asset Sent 1000000

Again we see that 1 million units were issued, only this time the asset is designated as UNLOCKED. What this means is that we can REISSUE it, i.e. make another issuance call and create more units.

When an unlocked asset is reissued we must specify the issuance address by adding an issueAddress key to the asset definition. So let's do that and reissue our U5haTxTknzcq94czuXQRHa7Nw38BUxnQWAX6w asset on the issuance address mpAUurhbWXFtczKVPn7iLf7rfcDhMdH6tH:

issueAddress = 'mpAUurhbWXFtczKVPn7iLf7rfcDhMdH6tH'

var asset = {
amount: 1000000,
reissueable: true,
issueAddress: issueAddress
}

var json_data = {
jsonrpc: "2.0", // mandatory
method: "issueAsset", // mandatory
id: "1", // mandatory if response is needed
params: asset // quary parameters
}

postToApi('', json_data, function(err, body){
if (err) console.log('error: ',err);
console.log(JSON.stringify(body))
});

And the response we get is:

{ 
jsonrpc: '2.0',
id: '1',
result: { txHex: '0100000001a60a3017dd145682ba55e06fe8069cb10bbab0adf27d5493d36a9b04ea9719b70000000000ffffffff0358020000000000001976a9145ed9f47408f7bc2567b8ef7da07c17e7e06f382c88ac00000000000000000c6a0a4343010526440026440078050000000000001976a9145ed9f47408f7bc2567b8ef7da07c17e7e06f382c88ac00000000',
assetId: 'U5haTxTknzcq94czuXQRHa7Nw38BUxnQWAX6w',
multisigOutputs: [],
txid: 'a9918d8081a13ba6550f0dc8f52266b810447d05df8395ad59919a2bcc54ae56',
receivingAddresses:
[ { address: 'mpAUurhbWXFtczKVPn7iLf7rfcDhMdH6tH',
amount: 1000000 } ],
issueAddress: 'mpAUurhbWXFtczKVPn7iLf7rfcDhMdH6tH' } }

So it looks like we succeeded in issuing the same assetID on the same address. Let's verify that with the explorer by looking at the asset:

ASSET NAME: N/A                          UNLOCKED ASSET
ISSUANCE
Name Issuer Amount utxo
U5haTxTknzcq94czuXQRHa... 1000000 72ea2228a6e555228a4e84685932eac1b395bfe512e81ce8bf9f27649be14dff
U5haTxTknzcq94czuXQRHa... 1000000 a9918d8081a13ba6550f0dc8f52266b810447d05df8395ad59919a2bcc54ae56

HOLDERS
Address Amount
mpAUurhbWXFtczKVPn7iLf7rfcDhMdH6tH 2000000

TRANSFER TRANSACTIONS
No Transactions Found
ISSUE TRANSACTIONS
72ea2228a6e555228a4e84685932ea...
Sent 0.00002 Asset Sent 1000000
a9918d8081a13ba6550f0dc8f52266...
Sent 0.00002 Asset Sent 1000000

Indeed, now there are 2 million units, both still sitting in the issuance address.

As an aside, let's try to issue an asset on an address to which we don't own the private key. An easy way to try that is to change one character in the wallet private seed. For example, below we changed the first letter a to b. The rest of the call is identical to what we did above:

issueAddress = 'mpAUurhbWXFtczKVPn7iLf7rfcDhMdH6tH'

var asset = {
amount: 1000000,
reissueable: true,
issueAddress: issueAddress
}

var json_data = {
jsonrpc: "2.0", // mandatory
method: "issueAsset", // mandatory
id: "1", // mandatory if response is needed
params: asset // quary parameters
}

postToApi('', json_data, function(err, body){
if (err) console.log('error: ',err);
console.log(JSON.stringify(body))
});

The response is

Addresss mpAUurhbWXFtczKVPn7iLf7rfcDhMdH6tH privateKey not found

which is to be expected, since obviously we shouldn't be able to issue an asset on an address that we don't control.

 

 

 

 

Issue and Send

One of the strengths of the new colored coins protocol is the ability to issue and send an asset within the same transaction.

Let's try to do that and issue 1 million units of an unlocked asset where upon issuance we send 250,000 units to another address. The destination address is added using the transfer key in the asset definition:

var asset = {
amount: 1000000,
reissueable: true,
transfer: [{
address: 'mvaHph557j63CyJxmEaJ8F38SC3cNetvaa', amount: 250000
}]
}

var json_data = {
jsonrpc: "2.0", // mandatory
method: "issueAsset", // mandatory
id: "1", // mandatory if response is needed
params: asset // asset json object
}

postToApi('', json_data, function(err, body){
if (err) console.log('error: ',err);
console.log(body)
});

Here is the response

{ 
jsonrpc: '2.0',
id: '1',
result: {
txHex: '0100000001239394eeeb02a16e49dd585d8c73223be28c524ac3e1b8463f3a8dd7ca240e750000000000ffffffff0358020000000000001976a914a52b6f9d2e1032c53e213b2e6d8710bf773f5d5d88ac00000000000000000c6a0a4343010526440021940078050000000000001976a914ab1bf706f8b437c269b3551e58b6279a117417d388ac00000000',
assetId: 'U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt',
txid: '2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453',
receivingAddresses: [{
amount: 250000,
address: 'mvaHph557j63CyJxmEaJ8F38SC3cNetvaa'
},{
amount: 750000,
address: 'mw7hLtuo9vnBNCs9PL7i2h7oqDfs4j8NJG'
}],
issueAddress: 'mw7hLtuo9vnBNCs9PL7i2h7oqDfs4j8NJG'
}
}

Let's look at the asset

HOLDERS
Address Amount
mvaHph557j63CyJxmEaJ8F38SC3cNetvaa 250000
mw7hLtuo9vnBNCs9PL7i2h7oqDfs4j8NJG 750000

TRANSFER TRANSACTIONS
No Transactions Found

ISSUE TRANSACTIONS
2cf2cbe850e9b6b1daf9b6cd190f1e...
Sent 0.00002 Asset Sent 1000000

This time we see that there are two holders to our asset, the new address mvaHph557j63CyJxmEaJ8F38SC3cNetvaa to which we sent 250,000 units and the issuance address mw7hLtuo9vnBNCs9PL7i2h7oqDfs4j8NJG which holds the remaining 750,000.

 

 

 

 

Asset Divisibility

All the assets we issued so far were issued with integral units. This makes sense for a large class of assets (e.g. representing a Movie Ticket). However, there are many use cases where an asset is naturally divisible. E.g. an asset that represents a currency.

We can issue divisible assets by adding a divisibility key to the asset definition. The value of that key defines the divisibility in terms of the number of places beyond the decimal point.

divisibility:0 corresponds to integers (1, 2, 3, etc...)
divisibility:1 corresponds to divisibility up to 1 decimal point (Numbers like 0.1, 0.9, 1.5, etc...)
divisibility:3 corresponds to divisibility up to 3 decimal points (Numbers like 0.001, 0.999, 123.456, etc...)

The Maximal divisibility supported by our SDK is 8 decimal points (mirroring the fact that 1 bitcoin is divisible to 100,000,000 satoshis).

The one thing to remember when issuing a divisible asset is that

the amount value always refers to the lowest denomination

For example, if we issue a divisibility 3 asset and specify amount 1, only 0.001 units of that asset will be issued.

Here is an example:

var asset = {
amount: 1,
divisibility:3
}

var json_data = {
jsonrpc: "2.0", // mandatory
method: "issueAsset", // mandatory
id: "1", // mandatory if response is needed
params: asset // asset json object
}

postToApi('', json_data, function(err, body){
if (err) console.log('error: ',err);
console.log(body)
});

The response is:

{ 
jsonrpc: '2.0',
id: '1',
result: { txHex: '01000000012d741dd70e927582dc810613dad5fa532b118e270de8df78f13425cddccf879d0000000000ffffffff0358020000000000001976a91496086b626ddb0003826c98d3f9d7acb970da223688ac00000000000000000b6a0943430105201300017078050000000000001976a91496086b626ddb0003826c98d3f9d7acb970da223688ac00000000',
assetId: 'LFiGGoWR3dQhGwCcnNEwaxubqPRr4zMZEHXTV',
multisigOutputs: [],
txid: '5c7a40c40a271fa67aeddb55d0e3d1d429a3f4c6932d5716dd42bef6f248c3bb',
receivingAddresses: [ { address: 'muCFjpj3p1wCWYBRD7AS4CLr79LRwyMVa5', amount: 1 } ],
issueAddress: 'muCFjpj3p1wCWYBRD7AS4CLr79LRwyMVa5' } }

Let's look at the asset in the explorer:

ASSET NAME: N/A               LOCKED ASSET
ISSUANCE
Name Issuer Amount utxo
LFiGGoWR3dQhGwCcnNEwax... 0.001 5c7a40c40a271fa67aeddb55d0e3d1d429a3f4c6932d5716dd42bef6f248c3bb

HOLDERS
Address Amount
muCFjpj3p1wCWYBRD7AS4CLr79LRwyMVa5 0.001

TRANSFER TRANSACTIONS
No Transactions Found

ISSUE TRANSACTIONS
5c7a40c40a271fa67aeddb55d0e3d1...
Sent 0.00002 Asset Sent 0.001

As another example, let's issue 10 units of a new asset that will be divisible to 1 decimal place, and in the same transaction also transfer 0.1 units to one address and 1 unit to another address:

var asset = {
amount: 100,
divisibility:1,
transfer: [{
address: 'miPznpFr7xQpWXp3dfYXBXKiVcdLKNPazT', amount: 1
},{
address: 'mmf1tBpqZqsKuHsrADZTYbm8sdCznci8nn', amount: 10
}]
}

var json_data = {
jsonrpc: "2.0", // mandatory
method: "issueAsset", // mandatory
id: "1", // mandatory if response is needed
params: asset // asset json object
}

postToApi('', json_data, function(err, body){
if (err) console.log('error: ',err);
console.log(body)
});

The response is:

{ 
jsonrpc: '2.0',
id: '1',
result: { txHex: '010000000164cca9e24675e2448fcf16d3d9af1f1949f46747e78f964e4c67f15ad6bf20e50000000000ffffffff0558020000000000001976a9141f978c90a1bf14a9f65ec9d24f07050a7242fde388ac58020000000000001976a914435713f35be02b0cd541d20ef55d87cea01ffcb088ac58020000000000001976a9144f5a837573766e16244dd953dbe08d504a26e97688ac0000000000000000106a0e4343010520130001010a02259030c8000000000000001976a9144f5a837573766e16244dd953dbe08d504a26e97688ac00000000',
assetId: 'LJja9jcs6g7iDxHfaAECzwfLbq1YuZbvR9jXs',
multisigOutputs: [],
txid: '25cea5a15841525d5d4105714cf43216a5f008c26c62995657fbfb40d4f79372',
receivingAddresses:
[ { address: 'miPznpFr7xQpWXp3dfYXBXKiVcdLKNPazT', amount: 1 },
{ address: 'mmf1tBpqZqsKuHsrADZTYbm8sdCznci8nn', amount: 10 },
{ address: 'mnkY7CR2qe4g4WXxH7CAcwioxkyBRyto4y', amount: 89 } ],
issueAddress: 'mnkY7CR2qe4g4WXxH7CAcwioxkyBRyto4y' } }

Let's look at the new asset in the explorer:

ASSET NAME: N/A                          LOCKED ASSET
ISSUANCE
Name Issuer Amount utxo
LJja9jcs6g7iDxHfaAECzw... 0.1 25cea5a15841525d5d4105714cf43216a5f008c26c62995657fbfb40d4f79372

HOLDERS
Address Amount
miPznpFr7xQpWXp3dfYXBXKiVcdLKNPazT 0.1
mmf1tBpqZqsKuHsrADZTYbm8sdCznci8nn 1.0
mnkY7CR2qe4g4WXxH7CAcwioxkyBRyto4y 8.9

TRANSFER TRANSACTIONS
No Transactions Found

ISSUE TRANSACTIONS
25cea5a15841525d5d4105714cf432...
Sent 0.00002 Asset Sent 10.0

Note that in the asset definition we were careful to specify all amounts in the lowest denomination (e.g. we wanted 10 units of a divisibility 1 asset so we specified the amount to be 100).

 

 

 

 

Send an Asset

In this section we will learn how to send an asset from one address to one or more other addresses by invoking the sendAsset method of a colu object.

For the purpose of this section, let's issue 500 units of a new asset, representing a ticket to a Broadway show

var request = require('request');

function postToApi(api_endpoint, json_data, callback) {
console.log(api_endpoint+': ', JSON.stringify(json_data));
request.post({
url: 'http://localhost:8081/'+api_endpoint,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
},
body: JSON.stringify(json_data)
},
function (error, response, body) {
if (error) {
return callback(error);
}
if (typeof body === 'string') {
body = JSON.parse(body);
}

return callback(null, body);
});
};

var asset = {
amount: 500,
metadata: {
'assetName': 'Chicago: The Musical',
'issuer': 'AMBASSADOR THEATRE, 219 West 49th Street, New York, NY 10019',
'description': 'Tickets to the show on 1/1/2016 at 8 PM'
}
}

var json_data = {
jsonrpc: "2.0", // mandatory
method: "sendAsset", // mandatory
id: "1", // mandatory if response is needed
params: sendAsset // asset json object
}

postToApi('', json_data, function(err, body){
if (err) console.log('error: ',err);
console.log(JSON.stringify(body))
});

Let's issue the asset by running the code, we get the following response:

{ 
jsonrpc: '2.0',
id: '1',
result: { txHex: '0100000001ea026b5c92d40f01243380b000507fdbb5d7615875be93112786c82ea28c98d1000000001976a9140eb3ffd2c449f56cfdf7f9cb8179fbcabce9c61a88acffffffff04ac0200000000000047512103ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2103263cd91de248d96c41b7b6fd4e6560c5ab624fec4ba038cbaf3516f10dfd8e3152ae58020000000000001976a9140eb3ffd2c449f56cfdf7f9cb8179fbcabce9c61a88ac0000000000000000206a1e4343010207af7a379075a2b5d55c152bee206f84f59bb3c8205201205210cc020000000000001976a9140eb3ffd2c449f56cfdf7f9cb8179fbcabce9c61a88ac00000000',
assetId: 'LE5arg1fawheJDvZEs9saPBoq9AENQGNxN9zr',
multisigOutputs: [],
txid: '99a508dfece3d5e4ea02aeec2eab3edc65926c174475ee0334fb1217345cfa65',
receivingAddresses: [ { address: 'mgrhPJzH37YctFsNtZGAHgvgEhJQ2A62ss', amount: 500 } ],
issueAddress: 'mgrhPJzH37YctFsNtZGAHgvgEhJQ2A62ss' } }

Confirming that we our new Chicago: The Musical asset was issued with 500 units.

Now let's send 1 of those units (or tickets) from the issuance address mgrhPJzH37YctFsNtZGAHgvgEhJQ2A62ss to a new address, say mfhdwaZd9csRDGVPBGVZeup45JpEGvYqhA (for example, this could be the wallet address of a customer), by invoking sendAsset.

One of the strengths of the new colored coins protocol is the ability to add metadata to every colored transaction. We will use this here and add another piece of metadata, specifying the exact seat in the theater.

To invoke this method we need to specify:


  • The Asset ID

  • The Source Address (from which we send)

  • The Target Address / Phone Number (to which we send)

  • The Amount of units to be sent

  • New Metadata (optional)

Here is the send call:

var request = require('request');

var assetId = 'LE5arg1fawheJDvZEs9saPBoq9AENQGNxN9zr'
var fromAddress = 'mgrhPJzH37YctFsNtZGAHgvgEhJQ2A62ss'
var toAddress = 'mfhdwaZd9csRDGVPBGVZeup45JpEGvYqhA'
var phoneNumber = '+1234567890'

function postToApi(api_endpoint, json_data, callback) {
console.log(api_endpoint+': ', JSON.stringify(json_data));
request.post({
url: 'http://localhost:8081/'+api_endpoint,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
},
body: JSON.stringify(json_data)
},
function (error, response, body) {
if (error) {
return callback(error);
}
if (typeof body === 'string') {
body = JSON.parse(body);
}

return callback(null, body);
});
};

var send = {
from: [fromAddress],
to: [{
address: toAddress,
assetId: assetId,
amount: 1
},{
phoneNumber: phoneNumber,
assetId: assetId,
amount: 1
}],
metadata: {
'assetName': '1 Ticket to see the Chicago Musical on 1/1/2016 at 8 PM',
'issuer': 'Ticket booth on Times Square',
'description': 'Seat 12 at row 10'
}
};

var json_data = {
jsonrpc: "2.0", // mandatory
method: "sendAsset", // mandatory
id: "1", // mandatory if response is needed
params: sendAsset // asset json object
}

postToApi('', json_data, function(err, body){
if (err) console.log('error: ',err);
console.log(JSON.stringify(body))
});

Note that we also added new metadata specifying extra information (the position of the particular seat in the theater).

Here is the response:

{ 
jsonrpc: '2.0',
id: '1',
result: { txHex: '010000000265fa5c341712fb3403ee7544176c9265dc3eab2eecae02eae4d5e3ecdf08a599010000001976a9140eb3ffd2c449f56cfdf7f9cb8179fbcabce9c61a88acffffffff8ef416f61e8ea138f65b05b661779dc2089a0c561307c93f6f1c80d938c6e75e000000001976a9140eb3ffd2c449f56cfdf7f9cb8179fbcabce9c61a88acffffffff04ac0200000000000047512103ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff21038389254c985afc9cec0ab69ee9feda2350328bb9004fe53cd72a1843cc5f2f4a52ae58020000000000001976a91402054158a7b64cc8a06827278145b880c3453b8b88ac00000000000000001c6a1a4343011186ac9b6ace74847c85c1825ce949db9b9d2e5ec4010124050000000000001976a9140eb3ffd2c449f56cfdf7f9cb8179fbcabce9c61a88ac00000000',
metadataSha1: '86ac9b6ace74847c85c1825ce949db9b9d2e5ec4',
multisigOutputs: [],
txid: 'b15a12441343e23fab484fd0be150d505fbb2d4769e67da0a69a413cb9b4724e' } }

You can use the explorer to confirm that indeed 1 unit of our Chicago: The Musical asset was sent to the new address mfhdwaZd9csRDGVPBGVZeup45JpEGvYqhA.

ASSET NAME: Chicago: The Musical                                                  LOCKED ASSET
ISSUANCE

Name Issuer Amount utxo
Chicago: The Musical AMBASSADOR THEATRE, 219 West 49th Street, New York, NY 10019 500 99a508dfece3d5e4ea02aeec2eab3edc65926c174475ee0334fb1217345cfa65

HOLDERS
Address Amount
mfhdwaZd9csRDGVPBGVZeup45JpEGvYqhA 1
mgrhPJzH37YctFsNtZGAHgvgEhJQ2A62ss 499

In the next section we describe how to retrieve asset data and metadata.

 

 

 

 

Query Asset Data

Assets are publicly available on the Blockchain and their metadata publicly available on Bittorent. Therefore, in order to query an asset, we don't need to specify a specific wallet seed, So let's just specify the Colored Coins API and Colu Server URLs

var settings = {
network: 'testnet'
}

In the next few sections we describe how to query for asset data and metadata. We begin with the general getassetdata method that retrieves the full set of data and metadata about an asset.

 

 

 

 

Asset Data

A complete record of the data about an asset can be fetched by calling the getAssetData method of the colu.coloredCoins object with the Asset ID.

Let's try that with the U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt asset that was created in the Issue an Asset|Issue and Transfer section.

var request = require('request');

function postToApi(api_endpoint, json_data, callback) {
console.log(api_endpoint+': ', JSON.stringify(json_data));
request.post({
url: 'http://localhost:8081/'+api_endpoint,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
},
body: JSON.stringify(json_data)
},
function (error, response, body) {
if (error) {
return callback(error);
}
if (typeof body === 'string') {
body = JSON.parse(body);
}

return callback(null, body);
});
};

var params = {
assetId: 'U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt'
}

var json_data = {
jsonrpc: "2.0", // mandatory
method: "coloredCoins.getAssetData", // mandatory
id: "1", // mandatory if response is needed
params: params // quary parameters
}

postToApi('', json_data, function(err, body){
if (err) console.log('error: ',err);
console.log(JSON.stringify(body))
});

Here is the response (note the addition of util.inspect to the log method so that also nested elements are fully displayed):

{ 
jsonrpc: '2.0',
id: '1',
result: { AssetData: { assetId: 'U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt',
assetAmount: 1000000,
assetTotalAmount: 1000000,
assetData:
[ { address: 'mvaHph557j63CyJxmEaJ8F38SC3cNetvaa',
amount: 250000,
utxo: '2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453:0',
metadata:
{ assetId: 'U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt',
divisibility: 0,
lockStatus: false,
someUtxo: '2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453:0',
totalSupply: 1000000,
numOfHolders: 2,
numOfTransfers: 0,
numOfIssuance: 1,
firstBlock: 508051,
issuanceTxid: '2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453' } },
{ address: 'mw7hLtuo9vnBNCs9PL7i2h7oqDfs4j8NJG',
amount: 750000,
utxo: '2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453:2',
metadata:
{ assetId: 'U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt',
divisibility: 0,
lockStatus: false,
someUtxo: '2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453:0',
totalSupply: 1000000,
numOfHolders: 2,
numOfTransfers: 0,
numOfIssuance: 1,
firstBlock: 508051,
issuanceTxid: '2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453' } } ] } }

The response details all the available data about the asset. Starting from the Asset ID and the total amount of available units (we will explain the difference between Amount and TotalAmount shortly) through the list of holding addresses and their crediting UTXOs.

In the above example, there are two different UTXOs, both from the same transaction 2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453:


  • 2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453:0
    The first output (index 0) where 250,000 units where transferred to the address mvaHph557j63CyJxmEaJ8F38SC3cNetvaa

  • 2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453:2
    The third output (index 2) where 750,000 units remained in the issuance address mw7hLtuo9vnBNCs9PL7i2h7oqDfs4j8NJG

The getAssetData method allows us to filter down the results by specifying two more parameters:


  • A list of addresses: Filter down to a subset of addresses by specifying a list of addresses under an addresses key

  • A Minimal number of confirmations: Filter down to data with a minimal number of confirmations (so that we only get UTXOs that were baked into blocks with at least the specified number of confirmations) by specifying the desired minimal number of confirmations under a numConfirmations key
  • As an example, let's look at the same query from before but filter down to only the issuance address mw7hLtuo9vnBNCs9PL7i2h7oqDfs4j8NJG and with at least 6 confirmations:

    var request = require('request');

    function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
    url: 'http://localhost:8081/'+api_endpoint,
    headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
    },
    body: JSON.stringify(json_data)
    },
    function (error, response, body) {
    if (error) {
    return callback(error);
    }
    if (typeof body === 'string') {
    body = JSON.parse(body);
    }

    return callback(null, body);
    });
    };

    var assetId = 'U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt'
    var addresses = ['mw7hLtuo9vnBNCs9PL7i2h7oqDfs4j8NJG']
    var confirmations = 6

    var params = {
    assetId: assetId,
    addresses: addresses,
    numConfirmations:confirmations
    }

    var json_data = {
    jsonrpc: "2.0", // mandatory
    method: "coloredCoins.getAssetData", // mandatory
    id: "1", // mandatory if response is needed
    params: params // quary parameters
    }

    postToApi('', json_data, function(err, body){
    if (err) console.log('error: ',err);
    console.log(JSON.stringify(body))
    });

    The response is:

    { 
    jsonrpc: '2.0',
    id: '1',
    result: { AssetData: { assetId: 'U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt',
    assetAmount: 750000,
    assetTotalAmount: 1000000,
    assetData:
    [ { address: 'mw7hLtuo9vnBNCs9PL7i2h7oqDfs4j8NJG',
    amount: 750000,
    utxo: '2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453:2',
    metadata:
    { assetId: 'U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt',
    divisibility: 0,
    lockStatus: false,
    someUtxo: '2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453:0',
    totalSupply: 1000000,
    numOfHolders: 2,
    numOfTransfers: 0,
    numOfIssuance: 1,
    firstBlock: 508051,
    issuanceTxid: '2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453' } } ] } }

    This example also clarifies the difference between assetAmount and assetTotalAmount. The former counts only units that match the filter.

    Finally, note that the assets we queried so far had no colored coins metadata. Let's run an example against an asset with metadata, like the LEUWnac9Pp7kZYC3W19xtVMVqL8jw6m19RZHu asset we just issued in the Issue with Metadata section:

    var request = require('request');

    function postToApi(api_endpoint, json_data, callback) {
    console.log(api_endpoint+': ', JSON.stringify(json_data));
    request.post({
    url: 'http://localhost:8081/'+api_endpoint,
    headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
    },
    body: JSON.stringify(json_data)
    },
    function (error, response, body) {
    if (error) {
    return callback(error);
    }
    if (typeof body === 'string') {
    body = JSON.parse(body);
    }

    return callback(null, body);
    });
    };

    var params = {
    assetId: 'LEUWnac9Pp7kZYC3W19xtVMVqL8jw6m19RZHu'
    }

    var json_data = {
    jsonrpc: "2.0", // mandatory
    method: "coloredCoins.getAssetData", // mandatory
    id: "1", // mandatory if response is needed
    params: params // quary parameters
    }

    postToApi('', json_data, function(err, body){
    if (err) console.log('error: ',err);
    console.log(JSON.stringify(body))
    });

    The response indeed contains the issuance metadata:

    { 
    jsonrpc: '2.0',
    id: '1',
    result: { AssetData: { assetId: 'LEUWnac9Pp7kZYC3W19xtVMVqL8jw6m19RZHu',
    assetAmount: 500,
    assetTotalAmount: 500,
    assetData:
    [ { address: 'n2SRqdXxbKpZPyVNBCdTM9Y5vHUcLEWVvE',
    amount: 500,
    utxo: 'f9fff185dc1df89ffe13cd7e5668a0af2953622176de91232ec1be975c6114c4:1',
    metadata:
    { assetId: 'LEUWnac9Pp7kZYC3W19xtVMVqL8jw6m19RZHu',
    divisibility: 0,
    lockStatus: null,
    someUtxo: 'f9fff185dc1df89ffe13cd7e5668a0af2953622176de91232ec1be975c6114c4:1',
    totalSupply: 500,
    numOfHolders: 1,
    numOfTransfers: 0,
    numOfIssuance: 1,
    firstBlock: 508271,
    issuanceTxid: 'f9fff185dc1df89ffe13cd7e5668a0af2953622176de91232ec1be975c6114c4',
    metadataOfIssuence:
    { data:
    { assetName: 'Mission Impossible 15',
    issuer: 'Fox Theatres',
    description: 'Movie ticket to see the New Tom Cruise flick' } },
    sha2Issue: '034976c163e25cfd8ff92c1962c2cbbb8fd60f3cf6a818e0bcac5fcb7e239ef332' } } ] } }

    Note the sha2Issue field. This is a hash of the metadata that is embedded in the blockchain (check out the first output script) so that we can verify that the torrent data (stored on the Bittorrent network, not on the blockchain) is the correct data.

    The getAssetData method is useful because it return a comprehensive answer about an asset's data. In the next couple of sections we cover some specialized queries that return smaller subsets of the full data relevant to an asset.

 

 

 

 

Asset Metadata

In this section we will learn about a specialized query tailored to getting asset metadata.

One of the strengths of the new colored coins protocol is the ability to add metadata to every colored transaction. Therefore, when we query for an asset's metadata we must specify not only the asset ID but the specific UTXO.

In the Asset Data section we retrieved data for the LEUWnac9Pp7kZYC3W19xtVMVqL8jw6m19RZHu asset.
Let's use that asset ID and the UTXO f9fff185dc1df89ffe13cd7e5668a0af2953622176de91232ec1be975c6114c4:1 to query for the metadata:

var assetId = 'LEUWnac9Pp7kZYC3W19xtVMVqL8jw6m19RZHu'
var utxo = 'f9fff185dc1df89ffe13cd7e5668a0af2953622176de91232ec1be975c6114c4:1'

and query the asset's metadata by invoking the getAssetMetadata method on the colu.coloredCoins object like so:

var request = require('request');

var assetId = 'LEUWnac9Pp7kZYC3W19xtVMVqL8jw6m19RZHu'
var utxo = 'f9fff185dc1df89ffe13cd7e5668a0af2953622176de91232ec1be975c6114c4:1'

function postToApi(api_endpoint, json_data, callback) {
console.log(api_endpoint+': ', JSON.stringify(json_data));
request.post({
url: 'http://localhost:8081/'+api_endpoint,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
},
body: JSON.stringify(json_data)
},
function (error, response, body) {
if (error) {
return callback(error);
}
if (typeof body === 'string') {
body = JSON.parse(body);
}

return callback(null, body);
});
};

var params = {
assetId: assetId,
utxo: utxo
}

var json_data = {
jsonrpc: "2.0", // mandatory
method: "getAssetMetadata", // mandatory
id: "1", // mandatory if response is needed
params: params // quary parameters
}

postToApi('', json_data, function(err, body){
if (err) console.log('error: ',err);
//console.log(JSON.stringify(body))
console.log(body)
});

Here is the response:

{ 
jsonrpc: '2.0',
id: '1',
result: { assetId: 'LEUWnac9Pp7kZYC3W19xtVMVqL8jw6m19RZHu',
divisibility: 0,
lockStatus: true,
someUtxo: 'f9fff185dc1df89ffe13cd7e5668a0af2953622176de91232ec1be975c6114c4:1',
totalSupply: 500,
numOfHolders: 1,
numOfTransfers: 0,
numOfIssuance: 1,
firstBlock: 508271,
issuanceTxid: 'f9fff185dc1df89ffe13cd7e5668a0af2953622176de91232ec1be975c6114c4',
metadataOfIssuence:
{ data:
{ assetName: 'Mission Impossible 15',
issuer: 'Fox Theatres',
description: 'Movie ticket to see the New Tom Cruise flick' } },
sha2Issue: '034976c163e25cfd8ff92c1962c2cbbb8fd60f3cf6a818e0bcac5fcb7e239ef332' } }

We recognize the data that we added at issuance in the Issue an Asset|Issue with Metadata section.
In more general cases (e.g. try this asset) we also get a metadataOfUtxo key detailing metadata that was added in transfer transactions.

 

 

 

 

Asset Holders

In this section we will work with a specialized query that returns only the list of addresses holding an asset.

For example, let's look at the U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt asset that was created in the Issue an Asset|Issue and Transfer section.

We can query for the list of addresses holding the asset and the amount of units held in each by invoking the getStakeHolders method on the colu.coloredCoins object like so:

var request = require('request');

var assetId = 'U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt'

function postToApi(api_endpoint, json_data, callback) {
console.log(api_endpoint+': ', JSON.stringify(json_data));
request.post({
url: 'http://localhost:8081/'+api_endpoint,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
},
body: JSON.stringify(json_data)
},
function (error, response, body) {
if (error) {
return callback(error);
}
if (typeof body === 'string') {
body = JSON.parse(body);
}

return callback(null, body);
});
};

var params = {
assetId: assetId
}

var json_data = {
jsonrpc: "2.0", // mandatory
method: "coloredCoins.getStakeHolders", // mandatory
id: "1", // mandatory if response is needed
params: params // quary parameters
}

postToApi('', json_data, function(err, body){
if (err) console.log('error: ',err);
console.log(JSON.stringify(body))
});

Here is the response:

{ 
jsonrpc: '2.0',
id: '1',
result: { assetId: 'U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt',
holders:
[ { address: 'mvaHph557j63CyJxmEaJ8F38SC3cNetvaa',
amount: 250000 },
{ address: 'mw7hLtuo9vnBNCs9PL7i2h7oqDfs4j8NJG',
amount: 750000 } ],
divisibility: 0,
lockStatus: false,
someUtxo: '2cf2cbe850e9b6b1daf9b6cd190f1e04eda43599e66f8600f118d5f5dae62453:0' } }

We recognize the two holding addresses mvaHph557j63CyJxmEaJ8F38SC3cNetvaa and mw7hLtuo9vnBNCs9PL7i2h7oqDfs4j8NJG holding 250,000 and 750,000 units respectively.

The response also includes the divisibility (zero in this case) and whether the asset is locked or not (unlocked in this case).

This method also supports filtering the results by the number of confirmations. We can add a minimal_confirmations parameter to the query like so

var request = require('request');

var assetId = 'U831iMR6M2aXdDSSmY3tyY7ZqpaCqLXQZKWJt'
var minimal_confirmations=1

function postToApi(api_endpoint, json_data, callback) {
console.log(api_endpoint+': ', JSON.stringify(json_data));
request.post({
url: 'http://localhost:8081/'+api_endpoint,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Content-Length': Buffer.byteLength(JSON.stringify(json_data), 'utf8')
},
body: JSON.stringify(json_data)
},
function (error, response, body) {
if (error) {
return callback(error);
}
if (typeof body === 'string') {
body = JSON.parse(body);
}

return callback(null, body);
});
};

var params = {
assetId: assetId,
numConfirmations: minimal_confirmations
}

var json_data = {
jsonrpc: "2.0", // mandatory
method: "coloredCoins.getStakeHolders", // mandatory
id: "1", // mandatory if response is needed
params: params // quary parameters
}

postToApi('', json_data, function(err, body){
if (err) console.log('error: ',err);
console.log(JSON.stringify(body))
});

In this case the response will only return the addresses that hold the asset with at least the desired number of confirmations.

 

 

 

 

Advanced Topics

In the Advanced Topics section we will show advance programming features.
We start with two topics:

1. Metadata Encryption

2. Multisig Address

For the Advance Topics code examples we will use Colu SDK

Metadata Encryption

Colu SDK/API supports metadata encryption.

Create a new file in the same directory where you installed Colu or Colu-Access module

Save the following into that file, say we call it metadata_encryption.js.

// metadata_encryption.js
var Colu = require('colu')

var privateSeed = null
var assetId;

var settings = {
network: 'testnet',
privateSeed: privateSeed
}

var colu = new Colu(settings)

As we shown in the Issue Asset section we need to add a metadata key to the asset definition.
So this time let's issue a new asset, a time machine in fact, with the following metadata:

// metadata_encryption.js
.......
metadata: {
assetName: "Time Machine",
issuer: "Dr. Emmet Brown",
description: "The flux capacitor will send us back to the future",
urls: [
{name: 'imdb',url: 'http://www.imdb.com/title/tt0088763/', mimeType: 'text/html', dataHash: '249e3e3c77d07d8fe8984a47bbbab8c89aeb8b1dadf4e2ff47db42a3e5a1c126'},
],
userData :{
meta: [
{key: 'Weight', value: 50000, type: 'Number'},
{key: 'Model', value: "Delorean", type: 'String'},
],
technology: 'flux capacitor 666',
"Undelrying Physics": 'This magnetic flux calculator calculates the magnetic flux of an object based on the magnitude of the magnetic field which the object emanates and the area of the object, according to the formula, Φ=BA, if the magnetic field is at a 90° angle (perpendicular) to the area of the object. If the magnetic field is not perpendicular to the object, then use the calculator below, which computes the magnetic flux at non-perpendicular angles. The magnetic flux is directly proportional to the magnitude of the magnetic field emanating from the object and the area of the object. The greater the magnetic field, the greater the magnetic flux. Conversely, the smaller the magnetic field, the smaller the flux. The area of the object has the same direct relationship. The greater the area of an object, the greater the flux. Conversely, the smaller the area, the smaller the magnetic flux.'
}
}

However, since our time travel technology is secret, we would like to encrypt the content of the Underlying Physics key. Colu uses the colored coins technology, and the colored coins protocol supports encrypting the value of userData keys (except for the ones that appear under the meta key array) using RSA public key encryption.

We can add an RSA public/private key pair by installing an additional library, called keypair.
To do that type in the console

sudo npm install keypair

RSA keys come in different formats so we need to specify if we are using the pem or der format. On top of that we need to specify which padding standard we are using for the key, pkcs1 or pkcs8.

We specify all this information in additional encryptions key in the metadata JSON, like so:

// metadata_encryption.js
.......
var keypair = require('keypair');
var pair = keypair();

var asset = {
amount: 50,
divisibility: 0,
reissueable: false,
metadata: {
assetName: "Time Machine",
issuer: "Dr. Emmet Brown",
description: "The flux capacitor will send us back to the future",
urls: [
{name: 'imdb',url: 'http://www.imdb.com/title/tt0088763/', mimeType: 'text/html', dataHash: '249e3e3c77d07d8fe8984a47bbbab8c89aeb8b1dadf4e2ff47db42a3e5a1c126'},
],
encryptions: [
{key: "Undelrying Physics", pubKey: pair['public'],format:"pem",type:'pkcs1' }
],
userData :{
meta: [
{key: 'Weight', value: 50000, type: 'Number'},
{key: 'Model', value: "Delorean", type: 'String'},
],
technology: 'flux capacitor 666',
"Undelrying Physics": 'This magnetic flux calculator calculates the magnetic flux of an object based on the magnitude of the magnetic field which the object emanates and the area of the object, according to the formula, Φ=BA, if the magnetic field is at a 90° angle (perpendicular) to the area of the object. If the magnetic field is not perpendicular to the object, then use the calculator below, which computes the magnetic flux at non-perpendicular angles. The magnetic flux is directly proportional to the magnitude of the magnetic field emanating from the object and the area of the object. The greater the magnetic field, the greater the magnetic flux. Conversely, the smaller the magnetic field, the smaller the flux. The area of the object has the same direct relationship. The greater the area of an object, the greater the flux. Conversely, the smaller the area, the smaller the magnetic flux.'
}
}
};

In this example we created a keypair object by requiring the keypair library, and instructed encrypting the value of the "Undelrying Physics" userData key using the public key of the keypair, using the 'pem' format and 'pkcs1' padding standard.

Now we just need to make the SDK issue asset call:

// metadata_encryption.js
.......
colu.on('connect', function () {
colu.issueAsset(asset, function (err, body) {
if (err) return console.error(err)
assetId = body.assetId
privateSeed = colu.hdwallet.getPrivateSeed()
console.log("PrivateSeed: ", privateSeed)
console.log("Body: ", body)
})
})

colu.init()

And run the code to get:

> node  metadata_encryption.js

Let's verify the encryption took place by retrieving the asset metadata (more details later in the Get Asset Data section):

// query_metadata.js
var Colu = require('colu')

var privateSeed = '1af0d2500cee79344a84bcf374c04b85835390d8a3e8565e594d307a28efb656'
var assetId = 'LDJMbzwCBWhrrXpKS7TrCfoAWYgXQhwZg1G6R'
var numConfirmations = 0
var addresses = null

var settings = {
network: 'testnet',
privateSeed: privateSeed
}

var args= {
assetId: assetId,
addresses: addresses,
numConfirmations: numConfirmations
}

var colu = new Colu(settings)
colu.on('connect', function () {
colu.coloredCoins.getAssetData(args, function (err, body) {
if (err) return console.error(err)
console.log("assetData: ", JSON.stringify(body))
})
})

colu.init()

The reply is:

{
"assetId":"LDJMbzwCBWhrrXpKS7TrCfoAWYgXQhwZg1G6R",
"assetAmount":50,
"assetTotalAmount":50,
"assetData":[{
"address":"n2t19a46cBs2DdHs2sqfRwPGhoQjvqmefR",
"amount":50,
"utxo":"66a681cf98ef2f03300c5c1aec7cd84862fe19567aa0334a424ff2a69cceebdc:2",
"metadata":{
"assetId":"LDJMbzwCBWhrrXpKS7TrCfoAWYgXQhwZg1G6R",
"divisibility":0,
"someUtxo":"66a681cf98ef2f03300c5c1aec7cd84862fe19567aa0334a424ff2a69cceebdc:2",
"totalSupply":50,
"numOfHolders":1,
"numOfTransfers":0,
"numOfIssuance":1,
"firstBlock":530925,
"issuanceTxid":"66a681cf98ef2f03300c5c1aec7cd84862fe19567aa0334a424ff2a69cceebdc",
"issueAddress":"n2t19a46cBs2DdHs2sqfRwPGhoQjvqmefR",
"metadataOfIssuence":{
"data":{
"assetName":"Time Machine",
"issuer":"Dr. Emmet Brown",
"description":"The flux capacitor will send us back to the future",
"urls":[{
"name":"imdb",
"url":"http://www.imdb.com/title/tt0088763/",
"mimeType":"text/html",
"dataHash":"249e3e3c77d07d8fe8984a47bbbab8c89aeb8b1dadf4e2ff47db42a3e5a1c126"
}],
"encryptions":[{
"key":"Undelrying Physics",
"pubKey":"-----BEGIN RSA PUBLIC KEY-----\nMIIBCgKCAQEA0hw6PRO9RpHRf/pdpEMfD01odzBTaheuA1JxunVTq+/X1hGSUrpRWMIM/tp8\n9DQod6K+6Bo/2CmoZxkWPOk45tbU9QE4Cb532n+MIkzsmbvmM+i49UXSqC8v44MGKTVLb7X2\nPogItSM3lqH4KpZR3cM/JDarfS1R77U/OMDZ/YECDPbcwKPdSLQHhWJ1c9cX5+0lCSDt1WXY\n4XX+hH64C+L/Ss4dMP2kpyHvbsBYpGdLu7AmcDmHtCOl2rXR1z4E0asYGiojw3PI56ATOndS\n30ABKKgQTAExjPQ24BtJYhfJ+zD5zHhztizPPfOwrID2HTfGwVTwfXinV4bpoFfwhwIDAQAB\n-----END RSA PUBLIC KEY-----\n"
,
"format":"pem",
"type":"pkcs1"
}],
"userData":{
"meta":[{
"key":"Weight",
"value":"50000",
"type":"Number"
},{
"key":"Model",
"value":"Delorean",
"type":"String"
}],
"technology":"flux capacitor 666",
"Undelrying Physics": "cv2gyjn/w9HOttpdhODnJcSGmOyhrTVsmAlnWDeIzh8VSvOGYXjM8Bkxwf9Ao5KhSf2GmFzIZNcbneNPIf1V2VnN2PBDv9oEXcZwKqf+2cJtWCK5CbwwCY4hBlSbtGT+Fs/8AWHc5blBREXZn9xMeubgUJ/H2dEiW5qK1cizlOsE/Qv8/GaRoRE7uFcCfhFqgJIFMQnYJeUtiYQoDkzsvgS84zKi1i2WjrCS6b99MQVE8mUvWP606V5nVDLDDSqe4L/pk5BCDMJ4y0ZusSvD3j7aC4jP7Z3Nyog7kcFUYFiYxVS2n6dL0vOr+gI3nvBLQda1GfQzoK3av1L8N4TkEEb9A9uJ26LUVERLoz5TRayUaGfY8a+QXnnb2Pifa69JsotTrG/qgXaltXXUo9xZwc8zKM2FkXN6iQK9g5R2Vya90t6n37ieGpC4QEFKhzvJ59VDpFNshkLhk5rxg84ulWItUILkHstGyJJblMdhNdcaecV57k2qiLbHHcz41JtbIv+mvmdHAkrc5Det+dRFvqzXN/jv6UVxk5bvX1pos+0c53m/JOgR3YIgxsHhCy8kNGj3dwy2jW8jvOll3xlDDWXbuh9fwQriJdFxh/7aknOoWc6h9g2XBSrf3p6wTEARhZ+QQKvLeY07KpzJ6w8f6lBiojcnpTqsRHOCFYjM3hsqmIcPrOPrWJG9HVk+Iwpi8XvITtuLUboKztot115CmSyat1HmJShgzmCM16W8ms7cG2qmkyUewxh0iu4jmLkVGIZRNbKRBNRJJ6t4thF0u9tNzs7PSW3ewjtppRRuqZcZvhzI5zNuOhYY9TNB+8kfrSQvUbtOGGKhjUS4T/yu4Q25oANsjTenQpEm3xxW63HIIGAGXTfzLV8pssaZtvsER37qZLacVY4XMY9NU6BiX4kyi9lb4foYJyMoqUGAOAqJJMheU+1qa4i4G0cspzzMopgCCaopzcG33eXVO5ncXVfmTc5Il8j9ZNhWVckzbFLPJRicrOrQIXW+rK9ZCfyog9jmRPupWXpgD88R4HxZWdObSN7tOTukcuKUtKhBVe8SXlE3501lMJSnwRxOt/djiUKRkQS4zbUsQGNfWVlpP0vwmTXO7jWPOKslOFVhBMVbTxr+HkzZAMGrN8a9gfTclBchNzHyJk9mSNSMcKfc6lzFKuIO2HA/IGUem2LgvlMgEmsjs7xRuFYRImlnhiajZ97P6g65n2pfsC3nE4nkP33Y6h1OlHqCtpSTKZJvlvVeNmeSvZAX811MeILunyjFcVSWDMpEaV4fIHc8bHeCYPKozUVneeYu75B5CgGZMhoqSBRUlHgSgvwFkqiEPAEWEWbSeFYFDrli/kNuOMmjKzHNZxOMXROmDQQ6Gzrcca3/JnMYiX7rEAuOZUYIrf6nX72ZovqWKsz0aI/WG8qb2nMfqfSkE2wwoG8MbxK8tvyPIZGWfySabN57zYGoyaJL5bjWuTGSFWEprgtIZyL8OIde6BTnSQONNBiwsd+S+0jvtV4CMwjNde0sBnDGzEViaqNOf1lU+5UQMKX9St6mG+foFfg3KBODN4PInw5UVuhT69ZIxXLvOazZ0ElpXIBKbgatw5IvvArplD4MJbNXi+XfMH76nQZ+1/MOy/oXtMhV5b33k0qqqB+Fn8pB0qwOVXLbC029FPP0vtW19/PKfNmlCjnnhedl4369u1U73gU="
}
}
},
"sha2Issue":"03e339927c047b00d57cea117b39b163c8bc14dfd852a1acfa6adcef50bf08d0e2"
}
}]
}

The value of the "Underlying Physics" key is now encrypted and no longer appears in plain text as in the asset issuance definition. The encryption public key is given (and it is the user's responsibility to take care of the encryption private key so that the value can later be decrypted).

 

 

 

 

Multisig Address

In this section we describe Colu SDK, and Colu-Access SDK support for multisignature Bitcoin Addresses.

The colored coins protocol lends full support for issuing an sending assets to and from multisignature addresses. Multisignature addresses (or multisig for short) are most preferably created by the client. However, the colored coins API (the technology used by Colu) also supports creating a multisig address for you.

We first describe how to generate a multisig address using nodejs. We proceed to issue assets on and transfer them to multisig addresses. Finally we discuss the API support for creating a multisig addresses.

 

 

 

 

Creating Multisig Address

In this section we describe how to create a multisignature addresses using nodejs

Create a new file in the same directory where you installed BitcoinJS and Node js

Save the following into that file, say we call it create_multisig_address.js.

// create_multisig_address.js
var bitcoin = require('bitcoinjs-lib');

function newMultisigAddress (m, N) {
var raw_privKeys = [];

for (var i = 1; i <= N; i++) {
var pk = bitcoin.ECKey.makeRandom();
raw_privKeys.push(pk);
}

var pubKeys = raw_privKeys.map(function (key) {
return key.pub.toHex();
})

var raw_pubkeys = pubKeys.map(bitcoin.ECPubKey.fromHex);
var redeemScript = bitcoin.scripts.multisigOutput(m, raw_pubkeys);
var scriptPubKey = bitcoin.scripts.scriptHashOutput(redeemScript.getHash());
var multisigAddress = bitcoin.Address.fromOutputScript(scriptPubKey, bitcoin.networks.testnet).toString();
return multisigAddress
}

This code creates an m out of N multisignature Address, by constructing the N underlying Public Keys.

In order to sign the transaction later we will need to know m out of the N private keys as well as the redeem script, so let's add some code to log this data:

// create_multisig_address.js
...........
console.log('redeemScript',redeemScript.toHex())
var wifs = raw_privKeys.map(function(key){return key.toWIF()})
console.log('privKeys (wif)',wifs)
console.log('pubKeys', pubKeys)

Let's take an example of 2 out of 3 multisig address

// create_multisig_address.js
...........
console.log('multisigAddress',newMultisigAddress(2,3))

Run that code by typing

> node create_multisig_address.js
----------------
multisigAddress 2Mu6MbHBxSpD2CLDpQRATKf3X8L4TSapmV9
redeemScript 522103ae3cf1075ab2c7544d973903c089295ab195af63a8f3c168c9b8901b457d9ce2210352f75a371a1331fa51a20b5e6e1e4ab8f86a1f65dd36fe44a9f7ce5d2a706946210330959f464f88f7294cc412a81f72f3cb817a2738a16e187d99b8e78c4ccf9e3b53ae
privKeys (wif) [ 'Kz6XuRHniKZfWxSLSC7YdN8AmB6oXaDSfHhxa6TPfwmcAC8URE7b',
'L3u4otRKpgBwC8JaJPGiWpYWaLQqQngVVhmG6bZXoEL6V85bywnd',
'KzaAL6uKn2zHUULhsESuDDNguS2TsjDZv3ebgiFbFzGSqg5oMZ89' ]
pubKeys [ '03ae3cf1075ab2c7544d973903c089295ab195af63a8f3c168c9b8901b457d9ce2',
'0352f75a371a1331fa51a20b5e6e1e4ab8f86a1f65dd36fe44a9f7ce5d2a706946',
'0330959f464f88f7294cc412a81f72f3cb817a2738a16e187d99b8e78c4ccf9e3b' ]
>

We see the multisig address (note it starts with 2 not with m or n like standard addresses), the redeem script and the set of 3 public and corresponding private keys.

 

 

 

 

Multisig Issuance Address

In this section we will issue an asset on the multisig address 2Mu6MbHBxSpD2CLDpQRATKf3X8L4TSapmV9 that was created in the previous section.

In fact, in terms of Colu's SDK it makes no difference at all that the address is a multisig address, we basically use the exact same code for issuing an asset, we only use a Multisig assress as our 'issueAddress':

// issue_asset.js
var bitcoin = require('bitcoinjs-lib');
var Colu = require('colu')

var privateSeed = null
var assetId;

var settings = {
network: 'testnet',
privateSeed: privateSeed
}

// asset data
var asset = {
"issueAddress": address,
"amount": 100,
divisibility: 0,
reissueable: false
}

var colu = new Colu(settings)
colu.on('connect', function () {
colu.issueAsset(asset, function (err, body) {
if (err) return console.error(err)
assetId = body.assetId
privateSeed = colu.hdwallet.getPrivateSeed()
console.log("PrivateSeed: ", privateSeed)
console.log("Body: ", body)
})
})

colu.init()

Running this code.

We got the Response:

> node issue_asset.js

And get the response:

Body:  {
txHex: '0100000001719317d1d89cbbe89f0783053b5a6ba16ab584ac6f9a60ed25cafe94c6f9f3680000000000ffffffff020000000000000000096a074343010527b010ce8101000000000017a9141442dada3e43b037543440bad2ad9695a360a6558700000000',
assetId: 'LGooTK9WEUNqSUu3i4CRJLxvejx9fbiZ2Gk1X',
txid: '8b3cc0067c4e79294e2204198a011e88ecb0b5b1717abe1a96fb07559692d7cd',
receivingAddresses: [{
amount: '100',
address: '2Mu6MbHBxSpD2CLDpQRATKf3X8L4TSapmV9'
}],
issueAddress: '2Mu6MbHBxSpD2CLDpQRATKf3X8L4TSapmV9'
}

Now, we issue 100 assets on a multisig address (2Mu6MbHBxSpD2CLDpQRATKf3X8L4TSapmV9).

 

 

 

 

Signing Multisig Transaction

In this section we sign the multisignature transaction that was generated in the previous section. We then proceed to broadcast the signed transaction to the Bitcoin testnet network.

Create a new file in the same directory where you installed BitcoinJS and Node js

Save the following into that file, say we call it sign_multisig.js.

This code uses the bitcoinjs-lib library as well as 2 of the three private keys and the redeem script that were created with the multisig address 2Mu6MbHBxSpD2CLDpQRATKf3X8L4TSapmV9 in the previous section.

// sign_multisig.js
var bitcoin = require('bitcoinjs-lib');

var privKeys = [ 'Kz6XuRHniKZfWxSLSC7YdN8AmB6oXaDSfHhxa6TPfwmcAC8URE7b','L3u4otRKpgBwC8JaJPGiWpYWaLQqQngVVhmG6bZXoEL6V85bywnd','KzaAL6uKn2zHUULhsESuDDNguS2TsjDZv3ebgiFbFzGSqg5oMZ89'];

var redeemScript = '522103ae3cf1075ab2c7544d973903c089295ab195af63a8f3c168c9b8901b457d9ce2210352f75a371a1331fa51a20b5e6e1e4ab8f86a1f65dd36fe44a9f7ce5d2a706946210330959f464f88f7294cc412a81f72f3cb817a2738a16e187d99b8e78c4ccf9e3b53ae';

var txHex = '0100000001719317d1d89cbbe89f0783053b5a6ba16ab584ac6f9a60ed25cafe94c6f9f3680000000000ffffffff020000000000000000096a074343010527b010ce8101000000000017a9141442dada3e43b037543440bad2ad9695a360a6558700000000'

var tx = bitcoin.Transaction.fromHex(txHex);

var txb = bitcoin.TransactionBuilder.fromTransaction(tx);

var rawSignedTransaction;

txb.tx.ins.forEach(function(input, i) {

var txid = bitcoin.bufferutils.reverse(input.hash).toString('hex');

txb.sign(i, bitcoin.ECKey.fromWIF(privKeys[0]), bitcoin.Script.fromHex(redeemScript));
txb.sign(i, bitcoin.ECKey.fromWIF(privKeys[1]), bitcoin.Script.fromHex(redeemScript));

try {
rawSignedTransaction = txb.build().toHex();

console.log('Successfully signed.');
} catch (e) {
if ('Transaction is missing signatures' === e.message) {
rawSignedTransaction = txb.buildIncomplete().toHex();
} else if ('Not enough signatures provided' === e.message) {
console.log('Not enough signatures provided');

rawSignedTransaction = txb.buildIncomplete().toHex();
} else {
console.log(e);
}
}
});

console.log(rawSignedTransaction);

Note how this code uses only the first and second private keys (we could have used any 2 out of the 3) and the redeem script.

Use our explorer to verify that resulting issuance transaction indeed issued 100 units of the new LGooTK9WEUNqSUu3i4CRJLxvejx9fbiZ2Gk1X asset on our funded multisig address 2Mu6MbHBxSpD2CLDpQRATKf3X8L4TSapmV9.

In exactly the same way, one can use multisig addresses in transferring assets. The only difference from previous code is the way the transaction is signed

 

 

 

 

Auto-Generated Multisig

The Colu SDK/API can creates a multisig address for you from a list of public keys.

While this option may be easier to use, openly sending the list of public keys exposes some security and privacy concerns (at least in principle).

In this case we use the pubKeys,m API endpoints instead of the address endpoint.
The pubkeys endpoint expects an array of N public keys and the integer m<=N is the minimal number of private keys needed to sign the transaction and release the funds in the associated multisignature address.

Here is an example of transferring the asset LGGxrFrEE2MhYoDrqzuXXg136rRY6mHScFshW from the funded issuance address (you should use the funded address created during setup) to the multisig address 2Mu6MbHBxSpD2CLDpQRATKf3X8L4TSapmV9 that was created in a previous section, by providing the three underlying public keys:

[ '03ae3cf1075ab2c7544d973903c089295ab195af63a8f3c168c9b8901b457d9ce2',
'0352f75a371a1331fa51a20b5e6e1e4ab8f86a1f65dd36fe44a9f7ce5d2a706946',
'0330959f464f88f7294cc412a81f72f3cb817a2738a16e187d99b8e78c4ccf9e3b' ]

create a new file in the same directory where you installed BitcoinJS and Node js

save the following into that file, say we call it transfer_to_pubkeys_multisig.js.

As before, we require the dependencies and use the postToApi function and our funded address (you should use the funded address created during setup.)

// transfer_pubkeys_multisig.js
var bitcoin = require('bitcoinjs-lib');
var Colu = require('colu')

var privateSeed = '09357bde26559b424a1c50b7228aa7283b6d36d277e9b8d3d2f9a8f3fae20963'
var assetId = 'LEuQv9iXrfXAvV8T7BG4ykJeErtF1b28YUjz4'
var issuance_address = 'n2t19a46cBs2DdHs2sqfRwPGhoQjvqmefR';

var settings = {
network: 'testnet',
privateSeed: privateSeed
}

var pubKeys = [ '03ae3cf1075ab2c7544d973903c089295ab195af63a8f3c168c9b8901b457d9ce2',
'0352f75a371a1331fa51a20b5e6e1e4ab8f86a1f65dd36fe44a9f7ce5d2a706946',
'0330959f464f88f7294cc412a81f72f3cb817a2738a16e187d99b8e78c4ccf9e3b' ]

var m = 2;
var send_asset = {
from: [issuance_address],
to: [{
pubKeys:pubKeys,
m:2,
amount: 10,
assetId: 'LGGxrFrEE2MhYoDrqzuXXg136rRY6mHScFshW'
}]
};

var colu = new Colu(settings)
colu.on('connect', function () {
colu.sendAsset(send_asset, function (err, body) {
if (err) return console.error(err)
console.log("Body: ", body)
})
})

colu.init()

Note how the code is essentially the same as in the Colu SDK | Send Asset section, except for replacing the address: to_address key-value pair with pubKeys,m.

Now run the code:

> node  metadata_encryption.js

And get the response:

{
"txHex": "0100000001818ee20e62fb52f1bac564f85f468a94538bfe62aea3e7f1bea71e39540bc3cf0200000000ffffffff03580200000000000017a9141442dada3e43b037543440bad2ad9695a360a655870000000000000000086a0643430115000a4c6d0100000000001976a914ea55c2430dca31e56ef5ae55c2863dae65df908688ac00000000",
"metadataSha1": "c35d66637424d749c5c89f1b94e18724c9b7cc10",
"multisigOutputs": [{
"index": 0,
"reedemScript": "522103ae3cf1075ab2c7544d973903c089295ab195af63a8f3c168c9b8901b457d9ce2210352f75a371a1331fa51a20b5e6e1e4ab8f86a1f65dd36fe44a9f7ce5d2a706946210330959f464f88f7294cc412a81f72f3cb817a2738a16e187d99b8e78c4ccf9e3b53ae",
"address": "2Mu6MbHBxSpD2CLDpQRATKf3X8L4TSapmV9"
}],
"txid": "d732eae09c6a6b2fa9094e32f95343297ed3136526dd72e7664f60657f6b094a"
}

contains on top of the usual txHex key (which we will soon sign), also a multisigOutputs key whose value give the correct redeem script and the multisig address 2Mu6MbHBxSpD2CLDpQRATKf3X8L4TSapmV9 that were obtained directly in the Create Multisig Address section.

Use our explorer to verify that resulting transfer transaction sent 10 units of the LGGxrFrEE2MhYoDrqzuXXg136rRY6mHScFshW asset from our funded address n2t19a46cBs2DdHs2sqfRwPGhoQjvqmefR to the multisig address 2Mu6MbHBxSpD2CLDpQRATKf3X8L4TSapmV9.

 

 

 

 

SDK Explorer

Use the SDK explorer to browse the different methods of the SDK and easily generate code templates to test and explore Colu's platform.
The SDK runs within the browser and enable developers to run SDK methods on mainnet or testnet environment.
The SDK explorer enables toggling between a simple form view or code editor view.
Select Method
Method documentation
TestNet
MainNet
Form
Code editor