June 27, 2017, 02:57:19 pm

Author Topic: issue colored coins  (Read 3843 times)

wenchan3

  • Newbie
  • *
  • Posts: 8
    • View Profile
issue colored coins
« on: April 13, 2015, 09:23:32 am »
hello, i'm newbie here,

i run this nodejs code:

Code: [Select]
var request = require('request');

request({
  method: 'POST',
  url: 'https://api.coinprism.com/v1/issueasset?format=json',
  headers: {
    'Content-Type': 'application/json'
  },
  body: "{  \"fees\": 1000,  \"from\": \"1Esd2TsA4gTS6YPeenxUMrxt246JbTg8Dt\",  \"address\": \"akZecC7M5CtDHstuWhq2Rs41anNEQb8yqvX\",  \"amount\": \"60\",  \"metadata\": \"u=https://site.com/assetdef\"}"
}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});


and i get this responds :
status 200
Code: [Select]
Headers: {"cache-control":"no-cache","pragma":"no-cache","content-type":"application/json; charset=utf-8","expires":"-1","server":"Microsoft-IIS/8.5","date":"Mon, 13 Apr 2015 10:24:10 GMT","content-length":"872"}
Response: {"inputs":[{"output_hash":"39ba16f62531ede4787f37368a8a137944fab754762fc42d547a5af7c2da12ee","output_index":2,"value":159600,"addresses":["1Esd2TsA4gTS6YPeenxUMrxt246JbTg8Dt"],"script_signature":"76a914982c817091bd594e12cc3e4b5ba7acd832ff731388ac","asset_id":null,"asset_quantity":null}],"outputs":[{"index":0,"value":600,"addresses":["1PgiwwXjjQKc1ek9fCvFDC71Sm4Ea9y2j7"],"script":"76a914f8d6016baa108ef8b8f91111312e1eba0f65214a88ac","asset_id":"AGJacxjmHwpEXbRFPGcsEdHkzu73tdoY2f","asset_quantity":"60"},{"index":1,"value":0,"addresses":[],"script":"6a224f410100013c1b753d68747470733a2f2f736974652e636f6d2f6173736574646566","asset_id":null,"asset_quantity":null},{"index":2,"value":158000,"addresses":["1Esd2TsA4gTS6YPeenxUMrxt246JbTg8Dt"],"script":"76a914982c817091bd594e12cc3e4b5ba7acd832ff731388ac","asset_id":null,"asset_quantity":null}],"amount":158600,"fees":1000}


update:
Quote
when i checked the output hash with coinprism.info, i get this :


that's a transaction that i made 1 hour ago,
in my nodejs code, i set the quantity with 60

and now, i'm about to sign this transaction...
i'm gonna use code from this example:
http://docs.coinprism.apiary.io/#reference/transaction-signing-and-broadcasting/sign-an-unsigned-raw-transaction/post
Code: [Select]
var request = require('request');

request({
  method: 'POST',
  url: 'https://api.coinprism.com/v1/signtransaction',
  headers: {
    'Content-Type': 'application/json'
  },
  body: "{  \"transaction\": \"0100000001d238c42ec059b8c7747cd51debb4310108f6279d14957472822cf061a660828b000000001976a914760fdb3483204406ddb73a45b20b7c9be61d0a7e88acffffffff0288130000000000001976a91430a5d35558ade668b8829a2a0f60a3f10358327e88ac306f0100000000001976a914760fdb3483204406ddb73a45b20b7c9be61d0a7e88ac00000000\",  \"keys\": [    \"D8414E7062013DD24D3A3E71EFA8C72142A63F45E3B1AFA4653AFDFD9BC8D67E\"  ]}"
}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});

but, i don't know how to get raw transaction code : "0100000001d238c42ec059b8c7747cd51debb4310108f6279d14957472822cf061a660828b000000001976a914760fdb3483204406ddb73a45b20b7c9be61d0a7e88acffffffff0288130000000000001976a91430a5d35558ade668b8829a2a0f60a3f10358327e88ac306f0100000000001976a914760fdb3483204406ddb73a45b20b7c9be61d0a7e88ac00000000" and keys : D8414E7062013DD24D3A3E71EFA8C72142A63F45E3B1AFA4653AFDFD9BC8D67E to run that code...

please help,

PS: sorry i'm not story teller type person, and sorry for my bad english
« Last Edit: April 13, 2015, 11:29:29 am by wenchan3 »

Coinprism

  • Admin
  • Administrator
  • Jr. Member
  • *****
  • Posts: 62
    • View Profile
    • Coinprism
Re: issue colored coins
« Reply #1 on: April 15, 2015, 06:21:12 pm »
If you use 'https://api.coinprism.com/v1/issueasset?format=raw' instead of 'https://api.coinprism.com/v1/issueasset?format=json', it will return the raw transaction which you can then send to signtransaction.

The key is the private key for your address 1Esd2TsA4gTS6YPeenxUMrxt246JbTg8Dt represented in hex format.

wenchan3

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: issue colored coins
« Reply #2 on: April 16, 2015, 06:18:51 am »
i made new code :
Code: [Select]
var request = require('request');

request({
  method: 'POST',
  url: 'https://api.coinprism.com/v1/issueasset?format=raw',
  headers: {
    'Content-Type': 'application/json'
  },
  body: "{  \"fees\": 600,  \"from\": \"1Esd2TsA4gTS6YPeenxUMrxt246JbTg8Dt\",  \"address\": \"akZecC7M5CtDHstuWhq2Rs41anNEQb8yqvX\",  \"amount\": \"60\",  \"metadata\": \"u=https://site.com/assetdef\"}"
}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});


i get this response :
Code: [Select]
{"raw":"0100000001ee12dac2f75a7a542dc42f7654b7fa4479138a8a36377f78e4ed3125f616ba39020000001976a914982c817091bd594e12cc3e4b5ba7acd832ff731388acffffffff0358020000000000001976a914f8d6016baa108ef8b8f91111312e1eba0f65214a88ac0000000000000000246a224f410100013c1b753d68747470733a2f2f736974652e636f6d2f6173736574646566c06a0200000000001976a914982c817091bd594e12cc3e4b5ba7acd832ff731388ac00000000"}
and i run this code too:
Code: [Select]
var request = require('request');

request({
  method: 'POST',
  url: 'https://api.coinprism.com/v1/issueasset?format=json',
  headers: {
    'Content-Type': 'application/json'
  },
  body: "{  \"fees\": 600,  \"from\": \"1Esd2TsA4gTS6YPeenxUMrxt246JbTg8Dt\",  \"address\": \"akZecC7M5CtDHstuWhq2Rs41anNEQb8yqvX\",  \"amount\": \"60\",  \"metadata\": \"u=https://site.com/assetdef\"}"
}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});


and this is the response :
Code: [Select]
{"inputs":[{"output_hash":"39ba16f62531ede4787f37368a8a137944fab754762fc42d547a5af7c2da12ee","output_index":2,"value":159600,"addresses":["1Esd2TsA4gTS6YPeenxUMrxt246JbTg8Dt"],"script_signature":"76a914982c817091bd594e12cc3e4b5ba7acd832ff731388ac","asset_id":null,"asset_quantity":null}],"outputs":[{"index":0,"value":600,"addresses":["1PgiwwXjjQKc1ek9fCvFDC71Sm4Ea9y2j7"],"script":"76a914f8d6016baa108ef8b8f91111312e1eba0f65214a88ac","asset_id":"AGJacxjmHwpEXbRFPGcsEdHkzu73tdoY2f","asset_quantity":"60"},{"index":1,"value":0,"addresses":[],"script":"6a224f410100013c1b753d68747470733a2f2f736974652e636f6d2f6173736574646566","asset_id":null,"asset_quantity":null},{"index":2,"value":158400,"addresses":["1Esd2TsA4gTS6YPeenxUMrxt246JbTg8Dt"],"script":"76a914982c817091bd594e12cc3e4b5ba7acd832ff731388ac","asset_id":null,"asset_quantity":null}],"amount":159000,"fees":600}

and when i checked the "output_hash":"39ba16f62531ede4787f37368a8a137944fab754762fc42d547a5af7c2da12ee"

that's the transaction from 3 days ago,

PS: i want to create a new transaction / issue colored coins, using API

this is issue colored coins via coinprism website:

Coinprism

  • Admin
  • Administrator
  • Jr. Member
  • *****
  • Posts: 62
    • View Profile
    • Coinprism
Re: issue colored coins
« Reply #3 on: April 16, 2015, 08:31:56 pm »
Quote
and when i checked the "output_hash":"39ba16f62531ede4787f37368a8a137944fab754762fc42d547a5af7c2da12ee"

that's the transaction from 3 days ago,

Yes, this is normal as this is the output being spent.

What is your issue exactly?

wenchan3

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: issue colored coins
« Reply #4 on: April 17, 2015, 12:48:34 am »
i want to create a new transaction / issue colored coins, using API

this is issue colored coins via coinprism website:



and with this API, (i get this API from http://docs.coinprism.apiary.io/#reference/blockchain-query-apis/get-the-unspent-outputs-of-an-address "issue colored coins")
Code: [Select]
var request = require('request');

request({
  method: 'POST',
  url: 'https://api.coinprism.com/v1/issueasset?format=json',
  headers: {
    'Content-Type': 'application/json'
  },
  body: "{  \"fees\": 600,  \"from\": \"1Esd2TsA4gTS6YPeenxUMrxt246JbTg8Dt\",  \"address\": \"akZecC7M5CtDHstuWhq2Rs41anNEQb8yqvX\",  \"amount\": \"60\",  \"metadata\": \"u=https://site.com/assetdef\"}"
}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});



it's only view past transaction.. not to create new transaction

Coinprism

  • Admin
  • Administrator
  • Jr. Member
  • *****
  • Posts: 62
    • View Profile
    • Coinprism
Re: issue colored coins
« Reply #5 on: April 17, 2015, 01:09:27 am »
You need to perform 3 calls in total:

- Create the issuance transaction
- Sign it
- Broadcast it

wenchan3

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: issue colored coins
« Reply #6 on: April 17, 2015, 03:45:06 am »
today i run the test again with this code:
Code: [Select]
var request = require('request');

request({
  method: 'POST',
  url: 'https://api.coinprism.com/v1/issueasset?format=json',
  headers: {
    'Content-Type': 'application/json'
  },
  body: "{  \"fees\": 600,  \"from\": \"1Esd2TsA4gTS6YPeenxUMrxt246JbTg8Dt\",  \"address\": \"akZecC7M5CtDHstuWhq2Rs41anNEQb8yqvX\",  \"amount\": \"60 \",  \"metadata\": \"u=https://site.com/assetdef\"}"
}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});




and the response :

Code: [Select]
{"inputs":[{"output_hash":"39ba16f62531ede4787f37368a8a137944fab754762fc42d547a5af7c2da12ee","output_index":2,"value":159600,"addresses":["1Esd2TsA4gTS6YPeenxUMrxt246JbTg8Dt"],"script_signature":"76a914982c817091bd594e12cc3e4b5ba7acd832ff731388ac","asset_id":null,"asset_quantity":null}],"outputs":[{"index":0,"value":600,"addresses":["1PgiwwXjjQKc1ek9fCvFDC71Sm4Ea9y2j7"],"script":"76a914f8d6016baa108ef8b8f91111312e1eba0f65214a88ac","asset_id":"AGJacxjmHwpEXbRFPGcsEdHkzu73tdoY2f","asset_quantity":"60"},{"index":1,"value":0,"addresses":[],"script":"6a224f410100013c1b753d68747470733a2f2f736974652e636f6d2f6173736574646566","asset_id":null,"asset_quantity":null},{"index":2,"value":158400,"addresses":["1Esd2TsA4gTS6YPeenxUMrxt246JbTg8Dt"],"script":"76a914982c817091bd594e12cc3e4b5ba7acd832ff731388ac","asset_id":null,"asset_quantity":null}],"amount":159000,"fees":600}

you can see the output hash from the response is : "39ba16f62531ede4787f37368a8a137944fab754762fc42d547a5af7c2da12ee"

and when i checked the hash detail with coinprism.info https://www.coinprism.info/tx/39ba16f62531ede4787f37368a8a137944fab754762fc42d547a5af7c2da12ee

it show transaction from Monday, April 13, 2015 9:31:36 AM
not showing mine today transaction... please help...


thanks...

« Last Edit: April 17, 2015, 07:56:56 am by wenchan3 »

Coinprism

  • Admin
  • Administrator
  • Jr. Member
  • *****
  • Posts: 62
    • View Profile
    • Coinprism
Re: issue colored coins
« Reply #7 on: April 22, 2015, 02:04:20 am »
This only builds the issuance transaction, but it's not signed and broadcasted. This is why you don't see your transaction in the blockchain.

To sign and broadcast the transaction you can either use the Coinprism API (check these API methods), or directly use Bitcoind.

The transaction 39ba16f62531ede4787f37368a8a137944fab754762fc42d547a5af7c2da12ee is the output you are spending. This is why it's in the past.
« Last Edit: April 22, 2015, 02:05:54 am by Coinprism »

wenchan3

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: issue colored coins
« Reply #8 on: April 22, 2015, 04:11:18 am »
thanks for the explanation,

now i'm about to sign this transaction,
i'm using the API you give, the API need raw hex and private key for the parameters,

you already told me how to get the raw hex,
to get raw is change format=json to format=raw in issue_colored_coins API,
so i change the format=json to format=raw, and run the code:

Code: [Select]
var request = require('request');

request({
  method: 'POST',
  url: 'https://api.coinprism.com/v1/issueasset?format=raw',
  headers: {
    'Content-Type': 'application/json'
  },
  body: "{  \"fees\": 600,  \"from\": \"1Esd2TsA4gTS6YPeenxUMrxt246JbTg8Dt\",  \"address\": \"akZecC7M5CtDHstuWhq2Rs41anNEQb8yqvX\",  \"amount\": \"60\",  \"metadata\": \"u=https://site.com/assetdef\"}"
}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});



and i get this response:
Code: [Select]
{"raw":"0100000001ee12dac2f75a7a542dc42f7654b7fa4479138a8a36377f78e4ed3125f616ba39020000001976a914982c817091bd594e12cc3e4b5ba7acd832ff731388acffffffff0358020000000000001976a914f8d6016baa108ef8b8f91111312e1eba0f65214a88ac0000000000000000246a224f410100013c1b753d68747470733a2f2f736974652e636f6d2f6173736574646566c06a0200000000001976a914982c817091bd594e12cc3e4b5ba7acd832ff731388ac00000000"}

but i still need 1 more parameter, that is the private key,
you said that private key for this address is "1Esd2TsA4gTS6YPeenxUMrxt246JbTg8Dt represented in hex format"
what you mean "represented in hex format"? should i change "1Esd2TsA4gTS6YPeenxUMrxt246JbTg8Dt" to hex string or what?

thanks,
« Last Edit: April 22, 2015, 04:13:09 am by wenchan3 »

Coinprism

  • Admin
  • Administrator
  • Jr. Member
  • *****
  • Posts: 62
    • View Profile
    • Coinprism
Re: issue colored coins
« Reply #9 on: April 22, 2015, 10:13:31 pm »
1Esd2TsA4gTS6YPeenxUMrxt246JbTg8Dt is not the private key, it's the address. You need the key for this address, represented in hex (i.e. not base 58).

wenchan3

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: issue colored coins
« Reply #10 on: April 23, 2015, 02:06:15 pm »
how to get the private key?

wenchan3

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: issue colored coins
« Reply #11 on: April 24, 2015, 08:01:31 am »
hello, now i know to get the private key,
when i created the new address, server will return the private key,
 
i already sign the transaction... and i get the raw transaction as return, it means sign transaction succed.

now i want to broadcast it, with raw transaction as parameter, and i get this error:

Code: [Select]
{"Message":"An error has occurred."}
and i run the code from apriary.coinprism too, and i get this error:

status code: 400

Code: [Select]
{
  "Message": "Error",
  "ErrorCode": "InvalidArgument"


i don't know if the parameter error or i'm using this api wrong way...
i wonder if you guys can help me...
thanks,

Coinprism

  • Admin
  • Administrator
  • Jr. Member
  • *****
  • Posts: 62
    • View Profile
    • Coinprism
Re: issue colored coins
« Reply #12 on: May 06, 2015, 01:57:52 am »
Please post your raw transaction so we can see what the problem is.

Note that signtransaction returning the transaction doesn't mean that all the inputs have been signed. If you provided the wrong key, it will return the same thing as you passed in input (i.e. still unsigned).

zenki

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: issue colored coins
« Reply #13 on: June 04, 2015, 10:54:01 am »
I have used this API to issue colored coin but when i excute my programma i had this message error:

status: 400
headers: {Server=[Microsoft-IIS/8.5], Cache-Control=[no-cache], Expires=[-1], Pragma=[no-cache], Content-Length=[50], Date=[Thu, 04 Jun 2015 09:51:35 GMT], Content-Type=[application/json; charset=utf-8]}
body:{"Message":"Error","ErrorCode":"InvalidApiMethod"}

16YaTfzUHr1hGd3oKGT6LvSoDxhY8k75Xd: represent asset Bitcoin address and akGWThqoomKuP8sDAMtZGznMNZZsi6Y9Mnu represent OAP of my asset.

Can you help me please?

Client client = ClientBuilder.newClient();
      Entity payload = Entity
            .json("{  'fees': 1000,  'from': '16YaTfzUHr1hGd3oKGT6LvSoDxhY8k75Xd', "
                  + " 'address': 'akGWThqoomKuP8sDAMtZGznMNZZsi6Y9Mnu',  'amount': '1', "
                  + " 'metadata': 'u=https://site.com/assetdef'}");
      Response response = client.target("https://api.coinprism.com")
            .path("/v1/issueasset?format=json")
            .request(MediaType.APPLICATION_JSON_TYPE).post(payload);

      System.out.println("status: " + response.getStatus());
      System.out.println("headers: " + response.getHeaders());
      System.out.println("body:" + response.readEntity(String.class));
   }