Getting started

First of all you will need an Ethereum account, that will serve as a hot wallet. You can generate one safely at MyEtherWallet

  • Type whatever password you like (no need to remember it);
  • Click Generate;
  • Copy and save Private Key (unencrypted) to a secure place. Please, beware that anyone who knows this private key, has access to your entire account;
  • Copy and save Your Address somewhere. This will serve as your Hot Wallet Address;
  • It is mandatory to have a separate Hot Wallet Address for every asset;
  • Maintain some ETH on the balance of your Hot Wallet Address.

Preconditions:

  • You know the smart contract address of an asset
  • You know the ICAP code for asset

Balance

This section will explain how to get balance information from your Hot Wallet Address.

Server-side Examples

Preconditions:

  • You know the asset of interest base unit (decimals) number
  • You have set in config.js the asset's contract address and baseUnit accordingly
  'address': '0xa3f84d45f7aef7018a5d66f44af780ec6022378a',
  'baseUnit': 8,

You can get balance by replacing the {address} with your Hot Wallet Address:

node get-balance.js {address}

Check out the example usages for Ruby and PHP in the repo, if necessary.

ETokenD configuration

Preconditions:

  • Start ETokenD with the following parameters: --assetaddress 0xe4c94d45f7aef7018a5d66f44af780ec6023378e --asset BCC --privatekey {PrivateKeyOfHotWallet}

You can get balance information with the following JSON RPC request:

curl localhost:18545 -d '{"jsonrpc":"2.0","method":"getbalance","params":[],"id":0}'

Receive deposits

This section will explain how to get paid.

Preconditions:

  • You know your company ICAP institution code, e.g. MYCO. You can request it through support.
  • Asset of interest ICAP currency code together with your company ICAP institution code is bound to your Hot Wallet Address. You can request it through support.
  • Start ETokenD with the following parameters:
--assetaddress 0xe4c94d45f7aef7018a5d66f44af780ec6023378e
--asset BCC
--institution {ICAPInstitutionCode}
--privatekey {PrivateKeyOfHotWallet}

Deposits

Call getnewaddress once for each user account:

curl localhost:18545 -d '{"jsonrpc":"2.0","method":"getnewaddress","params":[],"id":0}'

Assign resulting deposit address to the user account, and ask the user to make deposits to this address every time.

Invoices

Call getnewaddress once for each new invoice:

curl localhost:18545 -d '{"jsonrpc":"2.0","method":"getnewaddress","params":[],"id":0}'

Assign resulting address to the invoice, and ask the user to make an invoice payment to this address.

Process payment

So as to know when payment arrived, we suggest you set up a Notificator, deposit/invoice address can be accessed through notification.eventData.icap. Another option is to poll ETokenD for incoming transactions:

curl localhost:18545 -d '{"jsonrpc":"2.0","method":"listtransactions","params":[],"id":0}'

Deposit/invoice address can be accessed through transaction.icap.

Note: the payment's unique ID is transactionHash + logIndex, make sure to save it in order not to process the same payment twice.

Send payouts

This section will explain how to make payouts.

Server-side Examples

Preconditions:

  • You know the asset of interest base unit (decimals) number, found at Assets, e.g. CryptoCarbon 6
  • Set config.js parameters address (the asset's contract address) and baseUnit accordingly
  'address': '0xe4c94d45f7aef7018a5d66f44af780ec6023378e', // CC
  'baseUnit': 6,
  'icapAssetCode': 'BCC',
  'privateKey': {PrivateKeyOfHotWallet}

You can send funds, replacing the {destination} with the recipient's address or ICAP, and {amount} with the desired amount (1.1 will result in 1100000 CC being sent):

node send-tx.js {destination} {amount}

Check out the example usages for Ruby and PHP in the repo, if necessary.

Preconditions:

  • Start ETokenD with the following parameters: --assetaddress 0xe4c94d45f7aef7018a5d66f44af780ec6023378e --asset BCC --privatekey {PrivateKeyOfHotWallet}

Call sendtoaddress replacing the {destination} with the recipient's address or ICAP, and {amount} with the desired amount (1.1 will result in 1100000 CC being sent):

curl localhost:18545 -d '{"jsonrpc":"2.0","method":"sendtoaddress","params":["{destination}","{amount}"],"id":0}'

ETH through EToken

This section will explain how to work with ETH.

Setup

First of all, you need to activate your Hot Wallet Address to accept ETH in a WEI4 way:

  • Open Ambisafe Ethereum Utils
  • Press F12 to open a Developer Console
  • Execute the following code snippet, replacing the (privatekey) in the end with the private key of your Hot Wallet Address:
(function(key) {
  setPrivateKey(key);
  var wei4 = eth.contract([
    {
      "constant": false,
      "inputs": [
        {
          "name": "_enabled",
          "type": "bool"
        }
      ],
      "name": "setAutoDeposit",
      "outputs": [
        {
          "name": "",
          "type": "bool"
        }
      ],
      "type": "function"
    }
  ]).at('0x7660727d3cb947e807acead927ef3ede24c4a18d');
  log('Starting the activation process. It may take up to a couple of minutes.', $logs});
  safeTransactions([
    safeTransactionFunction(wei4.setAutoDeposit, [true], address, {waitReceipt: true}),
    syncFunction(function() {
      log(address + ' has been successfully activated to accept ETH in a WEI4 way.', $logs});
      log('You can close this page and proceed with the guide.', $logs});
    })
  ]);
})(privatekey);
  • To check balance, follow the Balance guide using the WE4 as ICAP currency code, and 0x7660727d3cb947e807acead927ef3ede24c4a18d as contract address, base unit is 0. It means that 1 WE4 equals 0.000000000000000001 ETH.
  • To send payouts, follow the Send payouts guide using the WE4 as ICAP currency code, and 0x7660727d3cb947e807acead927ef3ede24c4a18d as contract address, base unit is 0. It means that 1 WE4 equals 0.000000000000000001 ETH.

Receive ETH deposits

Preconditions:

  • You know your company ICAP institution code, e.g. MYCO. You can request it through contacting support
  • WE4 asset with your company ICAP institution code is bound to your Hot Wallet Address. You can request it through contacting support
  • You have EtherSweeper, which can be bought from Ambisafe
  • Start EtherSweeper with the following parameters: --secret {secretPhraseToEncryptPrivateKeys}
  • Check out EtherSweeper docs, keep the secret secure and backup the state file regularly

The process is as follows:

  1. Generate new ICAP address for the deposit/invoice. One way to do it is through ETokenD; another – to do it programmatically
  2. Assign resulting ICAP address to the deposit/invoice
  3. Call addroute replacing the {destination} with the address from the previous step:
curl localhost:28545 -d '{"jsonrpc":"2.0","method":"addroute","params":["{destination}"],"id":0}'
  1. In response you will get a simple ETH address. Show it to users so that they can make deposit or pay invoice. Note: the payments smaller than 0.01 ETH won't be swept, because this amount is reserved for the sweep itself
  2. Process payment.