Skip to content

LETMADE/assembly-coins-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

assembly-coins-node

AssemblyCoins API library client for node.js

This library is generated by alpaca

Installation

Make sure you have npm installed.

$ npm install assembly-coins-api

Versions

Works with [ 0.8 / 0.9 / 0.10 / 0.11 ]

Usage

var assemblyCoins = require('assembly-coins-api');

// Then we instantiate a client (as shown below)

Build a client

Without any authentication
var client = assemblyCoins.client('https://coins.assembly.com');

// If you need to send options
var client = assemblyCoins.client('https://coins.assembly.com', {}, clientOptions);

Client Options

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)

Response information

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'}
}
JSON response

When the response sent by server is json, it is decoded into a hash

response.body;
// >>> {'user': 'pksunkara'}

Method Options

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)

Request body information

Set request_type in options to modify the body accordingly

RAW request

When the value is set to raw, don't modify the body at all.

body = 'username=pksunkara';
// >>> 'username=pksunkara'
FORM request

When the value is set to form, urlencode the body.

body = {'user': 'pksunkara'};
// >>> 'user=pksunkara'
JSON request

When the value is set to json, JSON encode the body.

body = {'user': 'pksunkara'};
// >>> '{"user": "pksunkara"}'

Colors api

A colored coin represented on the bitcoin blockchain

var colors = client.colors();
Prompt API Server for New Coin Issuing Address (POST /colors/prepare)

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);
Check Holders of particular Coin Type (GET /colors/:color_address)

The following arguments are required:

  • color_address: The unique color address string identifying the color type
colors.get("string", options, callback);
Make New Coin Directly with Server Side Transaction Signing (POST /colors)

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);

api

var addresses = client.addresses();
Check Address Balances (GET /addresses/:public_address)

The following arguments are required:

  • public_address: The public Bitcoin address whose colored assets balance you wish to check.
addresses.balances("string", options, callback);
Generate Public/Private Address Pair (GET /addresses)
addresses.generate(options, callback);
Generate Public/Private Address Pair from Phrase (GET /addresses/brainwallet/:your_phrase)

The following arguments are required:

  • your_phrase: A passphrase that deterministically maps to a Bitcoin public/private keypair.
addresses.generateBrainwallet("string", options, callback);

api

var transactions = client.transactions();
Transfer Colored Coins with Server Side signing (POST /transactions/transfer)

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);
Push Raw Transaction to Bitcoin Network (POST /transactions)

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);
Parsed Open Assets Transactions in Block (GET /transactions/parsed/:block_height)

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);
Get Raw Transaction Information (GET /transactions/raw/:transaction_hash)

The following arguments are required:

  • transaction_hash: The Bitcoin transaction hash to lookup. Bitcoin transaction information is returned.
transactions.getRaw("string", options, callback);
Search for Verified Colored Coin Data on Transaction (GET /transactions/:transaction_hash)

The following arguments are required:

  • transaction_hash: The Bitcoin transaction hash to lookup. Verified Colored Coin Data is returned.
transactions.get("string", options, callback);

api

var messages = client.messages();
Write Multipart Statement on the Blockchain (POST /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);

Contributors

Here is a list of Contributors

TODO

License

MIT

Bug Reports

Report here.

Contact

James Peerless ([email protected])

About

Node Client Library for Assembly Coins API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published