AssemblyCoins API library client for node.js
This library is generated by alpaca
Make sure you have npm installed.
$ npm install assembly-coins-api
Works with [ 0.8 / 0.9 / 0.10 / 0.11 ]
var assemblyCoins = require('assembly-coins-api');
// Then we instantiate a client (as shown below)
var client = assemblyCoins.client('https://coins.assembly.com');
// If you need to send options
var client = assemblyCoins.client('https://coins.assembly.com', {}, clientOptions);
The following options are available while instantiating a client:
- base: Base url for the api
- api_version: Default version of the api (to be used in url)
- user_agent: Default user-agent for all requests
- headers: Default headers for all requests
- request_type: Default format of the request body
- response_type: Default format of the response (to be used in url suffix)
All the callbacks provided to an api call will recieve the response as shown below
// You can also omit the 'methodOptions' param below
client.klass('args').method('args', methodOptions, function (err, response) {
if (err) console.log(err);
response.code;
// >>> 200
response.headers;
// >>> {'x-server': 'apache'}
}
When the response sent by server is json, it is decoded into a hash
response.body;
// >>> {'user': 'pksunkara'}
The following options are available while calling a method of an api:
- api_version: Version of the api (to be used in url)
- headers: Headers for the request
- query: Query parameters for the url
- body: Body of the request
- request_type: Format of the request body
- response_type: Format of the response (to be used in url suffix)
Set request_type in options to modify the body accordingly
When the value is set to raw, don't modify the body at all.
body = 'username=pksunkara';
// >>> 'username=pksunkara'
When the value is set to form, urlencode the body.
body = {'user': 'pksunkara'};
// >>> 'user=pksunkara'
When the value is set to json, JSON encode the body.
body = {'user': 'pksunkara'};
// >>> '{"user": "pksunkara"}'
A colored coin represented on the bitcoin blockchain
var colors = client.colors();
The following arguments are required:
- issued_amount: Starting number of coins to be issued, declared in the Blockchain
- description: Description of the Coin Color, to be written permanently in the Blockchain
- coin_name: Name of the Coin Color, declared in the Blockchain
- email: For use with Assembly only. Not written in the blockchain
colors.prepare("integer", "string", "string", "string", options, callback);
The following arguments are required:
- color_address: The unique color address string identifying the color type
colors.get("string", options, callback);
The following arguments are required:
- public_address: The public Bitcoin address creating new coins. This will be the source address for this color type.
- private_key: The private key controlling the source address.
- name: The name of the new color type, to be written on the Blockchain.
- initial_coins: The number of coins to issue. More can be issued later. To be written on the Blockchain. Coins are sent back to this public address, from which they can later be transferred.
- description: The description of this coin color. This is to be written on the Blockchain. It is a permanent declaration of intent.
- email: The email of the coin creator. Stored by Assembly only. Not written on the Blockchain or shared with anyone.
- fee_each: The Bitcoin transaction fee to pay per transaction. Note that multiple transactions are necessary to create a new coin, thus the total fee will be some multiple of this number. We suggest 0.00005 BTC.
colors.create("string", "string", "string", "integer", "string", "string", "float", options, callback);
var addresses = client.addresses();
The following arguments are required:
- public_address: The public Bitcoin address whose colored assets balance you wish to check.
addresses.balances("string", options, callback);
addresses.generate(options, callback);
The following arguments are required:
- your_phrase: A passphrase that deterministically maps to a Bitcoin public/private keypair.
addresses.generateBrainwallet("string", options, callback);
var transactions = client.transactions();
The following arguments are required:
- from_public_address: The public address sending colored coins. It must have enough colored coins and bitcoins for the transfer transactions to succeed.
- from_private_key: The private key of the sending public address.
- transfer_amount: The number of colored coins to transfer. This is in units of the minimum increment for the color type.
- issuing_address: The source address of the color being transferred. This is the founder and controlling address of the color type and the only address that can issue further coins. It identifies the desired color to send, in case of color mixing.
- fee_each: The amount in Bitcoin transaction fees to spent per transaction. Suggested 0.00005.
- to_public_address: The destination for the transferred colored coins.
transactions.create("string", "string", "integer", "string", "float", "string", "string", options, callback);
The following arguments are required:
- transaction_hex: The raw transaction, in hex form, to be pushed directly to the Bitcoin Network.
transactions.createRaw("string", options, callback);
The following arguments are required:
- block_height: The height of the Bitcoin Block to inspect. Parsed Colored Coin Metadata will be presented for that Block. Metadata is not checked for legitimacy, merely interpreted from OPRETURNS.
transactions.getBlock("integer", options, callback);
The following arguments are required:
- transaction_hash: The Bitcoin transaction hash to lookup. Bitcoin transaction information is returned.
transactions.getRaw("string", options, callback);
The following arguments are required:
- transaction_hash: The Bitcoin transaction hash to lookup. Verified Colored Coin Data is returned.
transactions.get("string", options, callback);
var messages = client.messages();
The following arguments are required:
- public_address: Public Bitcoin address sending message.
- fee_each: Bitcoin transaction fee to spend per transaction. Depending on the length of the message, there may be multiple transactions.
- private_key: The private key of the Bitcoin address writing the message.
- message: The message itself to be written in the Blockchain. This message is divide into 40 byte blocks, written as separate OPRETURN transaction on the Blockchain. Numbers preceding each block allows for proper concatenation later.
messages.create("string", "float", "string", "string", options, callback);
Read stitched-together multi-part OP_RETURN statements issued by an address (GET /messages/:public_address)
The following arguments are required:
- public_address: The public Bitcoin address whose multi-part message are to be read. The stitched, concatenated version is presented.
messages.get("string", options, callback);
Here is a list of Contributors
MIT
Report here.
James Peerless ([email protected])