0.5.41 • Published 8 years ago

round-node v0.5.41

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

round-node: A Node.js client for the Gem API

The round client is designed to interact with Gem's API to make building blockchain apps drop dead simple. All the complexity of altcoin protocols and cryptography has been abstracted away so you can focus on building your product. Here are a few of the many great things the API and clients provide:

  • Multi-signature wallets with Gem as a cosigner
  • Bitcoin, Testnet, Litecoin, and Dogecoin support (multisig for all!)
  • Webhook notifications automatically subscribed for you
  • Integrated 2FA solution with arbitrary endpoints to build into your app
  • Simplified balance inqueries
  • Easy address management
  • Hardware Security Modules for co-signing key
  • Rules engine for transactions
  • SDKs for many popular languages

Support information

Installing round-node:

$ npm install round-node --save

Getting Started Tutorial

Table of Contents

Introduction

This tutorial will run you through the process of setting up an application with Gem, creating a wallet, funding an address and creating a transaction.

This tutorial assumes that you have completed the developer signup and that you have successfully installed the client

1. Get Your Credentials

  1. Get your credentials by going to the Gem Developer Console. You will need to grab an api_token, an admin_token, and your totp_secret. When you sign up/in you will see a default application that Gem has created for you. You will also see the api_token for that application as well. After you click on the application you will be directed to a page where you can view your totp_secret as well as create an admin_token. (Learn more about admin_tokens here).

[top]

2. Authenticate as an Application

In this step you will authenticate as one of your Gem applications.

 var creds = {
  api_token: API_TOKEN,
  admin_token: ADMIN_TOKEN,
  totp_secret: TOTP_SECRET
 }

 Round.client()
 .then(function (client) {
   return client.authenticate_application(creds);
 })
 .then(function (application) {
   ...
 })

[top]

3. Create a Wallet

In this step you will create a Gem wallet, which is a 2-of-3 multisig bitcoin wallet.

  1. Create a wallet:

      // application.wallets() returns a 'wallets' resource which
      // will allow you to create a wallet.
      application.wallets()
      .then(function (wallets) {
        return wallets.create({
          name: WALLET_NAME,
          passphrase: SECURE_PASSPHRASE
        }); 
      })
      .then(function (data) {
        var wallet = data.wallet;
        var backup_seed = data.backup_seed
      });

    IMPORTANT: Save the backup_seed somewhere safe, ideally on a piece of papper. You will need your backup_seed in case you forget your wallet's password. Gem wallets are multi-sig wallets and we only keep an encrypted copy of your primary pivate seed (which is decrypted client-side usig your wallet's passphrase). Therefor, if you forget your wallet's passphrase there is no way for us to recover a wallet without a backup_seed.

[top]

4. Access the Wallet and Default Account

Wallets and Accounts Gem wallets have accounts that are scoped to a network (i.e. bitcoin, testnet, litecoin, dogecoin). A wallet comes with a default account named 'default'. The default account is a bitcoin account (not testnet).

  1. Access the default account

      wallet.accounts()
      .then(function (accounts) {
        // get the default account
        return accounts.get('default');
      })
      .then(function (account) {
       ...
      })
  2. Or, create a new account

      wallet.accounts()
      .then(function (accounts) {
        return accounts.create({
          name: ACCOUNT_NAME,
          network: NETWORK_OF_YOUR_CHOICE
        });
      })
      .then(function (account) {
       ...
      })

[top]

5. Create and Fund an Address

account.addresses()
.then(function (addresses) {
  return addresses.create();
})
.then(function (address) {
// fund this address
 console.log(address.string)
})

Payments have to be confirmed by the network and on Testnet that can be slow. To monitor for confirmations: input the address into the following url https://live.blockcypher.com/btc-testnet/address/<YOUR ADDRESS>. The current standard number of confirmations for a transaction to be considered safe is 6.

You will be able to make a payment with only one confirmation, however. While you wait for that to happen, feel free to read more details about: Wallets and Accounts

[top]

6. Make a Payment

In this section you’ll learn how to create a payment using your wallet. Once your address gets one confirmation we’ll be able to send a payment out of the wallet. To make a payment, you'll unlock a wallet, generate a list of payees and then call the pay method.

```Javascript
var payees = [{
  address: '18XcgfcK4F8d2VhwqFbCbgqrT44r2yHczr',
  amount: 50000
}]
return account.pay({payees: payees});
})
.then(function (tx) {
  console.log(tx)
})
```

The pay call takes a list of payee objects. A payee is a dict of {'address':ADDRESS, 'amount':amount} where address is the bitcoin address and amount is the number of satoshis. utxo_confirmations default to 6 and represents the number of confirmations an unspent output needs to have in order to be selected for the transaction.

CONGRATS - now build something cool.

[top]

0.5.41

8 years ago

0.5.40

8 years ago

0.5.39

9 years ago

0.5.38

9 years ago

0.5.37

9 years ago

0.5.36

9 years ago

0.5.35

9 years ago

0.5.34

9 years ago

0.5.33

9 years ago

0.5.32

9 years ago

0.5.31

9 years ago

0.5.3

9 years ago

0.5.2

9 years ago

0.5.1

9 years ago

0.4.1

9 years ago

0.4.0

9 years ago

0.3.5

9 years ago

0.3.4

9 years ago

0.3.3

9 years ago

0.3.2

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.0

9 years ago

0.1.1-alpha1

9 years ago

0.1.0-alpha1

9 years ago