Client for the Gem cryptocurrency API
npm install round-node* 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
bash
$ npm install round-node --save
`
Getting Started Tutorial
#### Table of Contents
* Introduction
* 1. Get Your Credentials
* 2. Authenticate as an Application
* 3. Create a Wallet
* 4. Access the Wallet and Default Account
* 5. Create and fund an address
* 6. Make a Payment$3
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
$3
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]](README.md#getting-started-tutorial)
$3
In this step you will authenticate as one of your Gem applications.
`JavaScript
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]](README.md#getting-started-tutorial)
$3
In this step you will create a Gem wallet, which is a 2-of-3 multisig bitcoin wallet.1. Create a wallet:
`JavaScript
// 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]](README.md#getting-started-tutorial)
$3
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
`JavaSctipt
wallet.accounts()
.then(function (accounts) {
// get the default account
return accounts.get('default');
})
.then(function (account) {
...
})
`
2. Or, create a new account
`JavaSctipt
wallet.accounts()
.then(function (accounts) {
return accounts.create({
name: ACCOUNT_NAME,
network: NETWORK_OF_YOUR_CHOICE
});
})
.then(function (account) {
...
})
`
[[top]](README.md#getting-started-tutorial)
$3
`JavaSctipt
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/. 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]](README.md#getting-started-tutorial)
$3
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]](README.md#getting-started-tutorial)