This guide will describe how to install and run Element locally on a Linux machine
running Unbuntu 20.04.3 on either an x86_64 machine, or Raspberry Pi 4. This guide
will use the example name of ubuntu
(with lower-case u
) to describe the user
and default home directory of /home/ubuntu
.
This document will be similar to the Ganache-dev install with the two differences in this case are that:
- We will need to set up and fund a wallet for testnet
- We will be using a service provider for the Etherium Blockchain
Note Later versions of this document will include instructions on how to set up and run and Ethereum node locally.
- Install Dependencies
- Clone and Build the Repository
- Create and Fund a Wallet
- Infura Ethereum Provider
- Start Element Testnet:ropsten Node
- Run Create / Resolve Operation
- Resolve an Existing Did
Install IPFS
$ sudo snap install ipfs
$ ipfs init
$ sudo vim /lib/systemd/system/ipfs-daemon.service
--- Create File ---
[Unit]
Description=IPFS daemon
Wants=network.target
After=network.target
[Service]
User=ubuntu
Group=ubuntu
Type=simple
Environment=IPFS_PATH=/home/ubuntu/snap/ipfs/common
ExecStart=/snap/bin/ipfs daemon --migrate
ExecStop=/usr/bin/pkill -f ipfs
Restart=on-failure
RestartSec=10s
[Install]
WantedBy=multi-user.target
--- EOF ---
$ sudo systemctl start ipfs-daemon.service
$ sudo systemctl enable ipfs-daemon.service
Install MongoDB
$ wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
$ echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
$ sudo apt-get update
$ sudo apt-get install -y mongodb-org
$ sudo systemctl daemon-reload
$ sudo systemctl enable mongod.service
$ sudo systemctl start mongod.service
Install Nodejs (v14)
$ sudo apt install -y python-is-python3 make gcc
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
$ source ~/.bashrc
$ nvm install 14
$ nvm use 14
$ cd /home/ubuntu
$ git clone https://github.com/transmute-industries/sidetree.js.git
$ cd sidetree.js
$ npm i
Since we're using the Ropsten Ethereum testnet, we will need to create a wallet and then fund it from a wallet. We will create a wallet from a mnomic phrase. The first step will be to goto this Mnemonic Code Converter page.
- Make sure that
12
words are being generated - Click on the
GENERATE
button - You should have twelve words appear in the text area below
Once we have our twelve word phrase, we will use it to import a wallet. The wallet we will use is called MetaMask, which is implement with a browser extension. You can click on the following download link to get the appropriate install instructions for your browser.
Once the extension is installed, you will be greeted with the above welcome
screen. Click on the button to Get Started
.
From there, you will be given the option to import an existing wallet, or create a
new one. Since we have already created our mnemonic phrase, we want to click on the
Import Wallet
button.
From there you will be given the option to gather usage data or not. Select the option that you prefer.
To import your wallet, paste your twelve word mnemonic phrase that you generated
into the Secret Recovery Phrase
field. You will be required to create a password.
You will need this password to access your wallet from the browser, so make
it secure, but keep in mind that you will need to remember it. Once you are ready
click on the Import
button.
You should get a message that says "Congratulations". Click on the All Done
button, and we will proceed to describe how to fund the wallet.
The page should transition to our wallet. We want to click on the select
field in the top right hand corner that says Ethereum Mainnet
, and then
we want to click on the link that says Show/hide
test networks.
This will take us to a settings option that we want to toggle to ON
.
Once we do that, the top right select input should now show the Ropsten
test network. We want to click on that because that is what we will be funding.
To get our address, we can click on the header that says Account 1
at the top
to copy the address to the clickboard.
From there we want to goto the Ropsten Etereum Faucet (recomend using incognito tab),
and paste in our address. And then click on the Send me test Ether
button. You
should get a confirmation that says, "request added to the queue". Depending on availabity,
you might need to select a different faucet.
Once you have funds in your wallet, we're ready to move onto the next step of configuring our node to reference our wallet via the mnemonic string. With respect to the amount of funds needed to operate a node, Element should only use the mimimum transaction to send anchor requests to the smart contract. So topping up your wallet is only something that should be done rarely if ever with respect to testnet.
WARNING: You should never share or publish your mnemonic phrase. If you have too many funds in a wallet, then create a new wallet and transfer a minimum amount of funds into that new wallet. And then use the minimally funded wallet to run the Element node. For best practices on how to manage crypto funds, please refer to the policies outlined here.
In your browser navigate to https://infura.io. Then click on Sign Up
in the navigation bar.
Enter your email address, provide a secure password and click on the SIGN UP
button to submit the form.
3.3 A confirmation screen will appear indicating that a confirmation link was sent to your email.
Locate the confirmation email in your inbox. Click on the CONFIRM EMAIL ADDRESS
button in the mail body.
You will be redirected to the Infura dashboard. Click on the CREATE NEW PROJECT
button in the top right.
Select Ethereum
from the dropdown for the product, and provide element
for the name.
Under the KEYS
section, select ROPSTEN
from the endpoint dropdown. Our Ehtereum Provider will be the https link.
To use this service, you must edit the environment variable in the Sidetree.js
repository before starting the Sidetree-Element service. Specifically we want
to set MONGO_DB_CONNECTION_STRING
and ELEMENT_CONTENT_ADDRESSABLE_STORE_SERVICE_URI
to use the services running on localhost. For ETHEREUM_RPC_URL
we want to
provide our API url and key. And on ETHEREUM_MNEMONIC
/ ETHEREUM_PRIVATE_KEY
we
will need to provide the mnemonic phrase or private key for a minimally funded wallet
to use the service.
$ cd /home/ubuntu/sidetree.js/packages/dashboard
$ cp .env.ropsten.example .env.ropsten
$ vim .env.ropsten
--- Edit to Resemble the following ---
SIDETREE_METHOD='elem:ropsten'
# Sidetree Variables
MONGO_DB_CONNECTION_STRING='mongodb://localhost:27017/'
DATABASE_NAME='element-ropsten'
MAX_CONCURRENT_DOWNLOADS=20
BATCH_INTERVAL_IN_SECONDS=5
OBSERVING_INTERVAL_IN_SECONDS=5
# Element Node Variables
ELEMENT_CONTENT_ADDRESSABLE_STORE_SERVICE_URI='/ip4/127.0.0.1/tcp/5001'
ELEMENT_ANCHOR_CONTRACT="0x920b7DEeD5CdE055260cdDBD70C000Bbd5b30997"
ETHEREUM_RPC_URL='https://ropsten.infura.io/v3/[YOUR_PROJECT_API_KEY]'
ETHEREUM_PROVIDER=$ETHEREUM_RPC_URL
ETHEREUM_MNEMONIC='[YOUR_MNEMONIC_PHRASE]'
ETHEREUM_PRIVATE_KEY='[YOUR_PRIVATE_KEY]'
--- End Contents
We can then start the element node by running the following command.
$ npm run dev:ropsten
Once we have Element running on our local machine, we can then run a test operation to see if we are able to create and then resolve a did.
We can start by opening up localhost:3000
in our browser and then clicking on the Wallet
link on the "Manage" card.
From there we can click on the Create Wallet
button, this will create a private/public key pair to allow us to sign did's. Note: The wallet will throw an error when not used on localhost or https.
Once the wallet is created, you will be automatically redirected to the create
route. Can can then click on the CREATE DID
button to generate a did.
Once the operation is complete, you should see the confirmation above. To see if we can resolve the did, we can click on the underlined did to be redirected to the resolve page.
You should see a card that looks like the above image. You can then click on the arrows to show more information about the did.
If you want more information on how to use the API interact with dids, you can read the documentation at localhost:3000/docs
.
If you want to make sure that you can resolve an existing did, you can use
did:elem:ropsten:EiCtwD11AV9e1oISQRHnMJsBC3OBdYDmx8xeKeASrKaw6A
. You should see the
following information.