Skip to content

Latest commit

 

History

History
94 lines (61 loc) · 5.51 KB

File metadata and controls

94 lines (61 loc) · 5.51 KB

Examples

Setup

To run the examples we need to modify the file called '.env' in the root directory of the project and paste in the required variables that you will be securing. Then, you will need to create accounts and fund them, before adding further details to the '.env' file and securing it again.

Creating Accounts

You will need to have DLT accounts to create transactions. The following example will create and console log new DLT accounts for all of the Bitcoin, Ethereum, Substrate and XRP ledger distributed ledger technologies:

node examples/create-account/create-account.js

NOTE that key pairs can be reused on different DLT networks of the same DLT type including mainnets, so we recommend for you to only use these generated accounts on one particular DLT network.

TAKEAWAY: Do not mix the accounts that you use on testnets and mainnets!

Attaining Testnet Cryptocurrency

As you are interacting with permissionless DLT networks, youy will have to pay a transaction fee to get your transactions accepted on the DLT networks. If you are interacting with testnets, the transaction fee will actually be paid in a test cryptocurrency (typically without monetary value). But the transaction fee system is still present on the testnets, in order to accurately simulate the mainnets.

Therefore you will need to fund your account addresses before you can send transactions from those addresses. To fund your addresses on testnets, we can request a faucet to provide us some funds. These services are named as faucets as they "drip" funds to users that require them.

We list a few publicly available faucets options below:

Note that faucets can be occasionally empty or can change frequently, if your having trouble with all of the ones listed above for your desired DLT, have a Google and let us know if you find a better one.

IMPORTANT NOTE 1: For Bitcoin, Ethereum and Substrate DLTs, note that the faucet funding transactions needs to be in a block of the corresponding blockchain before it can be used. Whereas XRP ledger funds will be available as soon as you see the generated information on the XRP ledger faucet screen.

IMPORTANT NOTE 2: For Bitcoin you will need to note down the transactionId the faucet uses to provide you with funds. This is so you can prepare a transaction correctly later.

IMPORTANT NOTE 3: For Ethereum, there are many different test networks available (e.g. Ropsten, Rinkeby, Kovan,...). Tokens issued on one test network cannot be used on another test network. So make sure that any faucet you use is a Ropsten testnet faucet.

IMPORTANT NOTE 4: For XRP Ledger testnet, we recommend using the DLT account generated by the faucet (instead of the XRP Ledger account generated by the create account script above) as it automatically comes provided with testnet XRP.

Adding DLT accounts to the Environment File

To use these generated accounts (or any others), see the example /.env file. For ease of use, we have included some example secrets (used to generate accounts with the DLT native libraries) and addresses for accounts that have test tokens. But you can replace these examples with your own if required.

You will need to set the USER_NAME, PASSWORD, CLIENT_ID and CLIENT_SECRET parameters yourself, replacing the section on the right of the ='s sign with the corresponding information.

USER_NAME=your-overledger-devportal-email-address-here
PASSWORD=your-overledger-devportal-password-here
CLIENT_ID=your-overledger-devportal-application-client-id-here
CLIENT_SECRET=your-overledger-devportal-application-client-secret-here

PARTY_A_BITCOIN_SECRET=cTovDfJ5Mv1bDtt3FicjoNq4VpXCqEpGE4iegAejkDQr8sQ9N69p
PARTY_A_ETHEREUM_SECRET=0x822c2b2e7d1aa3f6f4d1f477980ca776f89b3937f915d829f851c33d11a0b103
PARTY_A_XRP_LEDGER_SECRET=spysfpdWC23TTVE3rYVKTbtpDgS7y
PARTY_A_SUBSTRATE_SECRET='link zebra solar rule liar rough boring build inflict moon risk panic'

PARTY_A_BITCOIN_ADDRESS=msRk9nw3qd6wQi9qsDVdxvg3aEmDygmmbx
PARTY_A_ETHEREUM_ADDRESS=0xa3d125A3eC50f6Bfc67Cf6503365720CFE41C867
PARTY_A_XRP_LEDGER_ADDRESS=rHWBwmC4k7cjMXqpebtn2tzm64d9nYQXm6
PARTY_A_SUBSTRATE_ADDRESS=5HY7UXhVKXRwtMb12kBV7tVZd5cjCsUCBaX8o3r5ebQcXhXn

NOTE: the addresses are provided so you understand what addresses were linked to the given secrets

Once you have created this file, you will need to secure it by using "secure-env". To do so, you should install this program via entering in the root folder:

npm install secure-env

or alternatively:

npm install -g secure-env

After it is installed, we can run the following command from the root folder of the project.

secure-env .env -s password

Make sure you change the password here as well as in any examples you would like to run.

Running

Each example contains detailed comments about various bits that need to be adjusted. To run an example, simply call the js file from the root folder of the project. E.g:

node examples/signing/ethereum-signing.js

The signing examples produce an output which you can send to the Overledger API.