This repository contains the backend for the SSI Service created by TNO. It should be run in conjunction with the other necessary services (frontend, irma, db, etc.). Deployment configurations for running the entire service are provided in a separate repository.
$ npm install
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
We use the typeorm
library for managing the database. A dev/prod and
nest/typeorm-cli compatible ormconfig can be found in
src/ormconfig.ts
. Some helper scripts have been defined in
package.js
.
# run typeorm command
$ npm run typeorm <your command>
# create new migration
$ npm run typeorm:migrate <migration name (PascalCase)>
# run migrations
$ npm run typeorm:run
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
The Jolocom connector will not work out-of-the-box. For more information, keep reading.
The default Jolocom implementation is built on top of the Ethereum Blockchain. The blockchain is used as the "Verifiable Data Registry". This registry allows DIDs to be translated into DID documents.
For testing purposes, the development version of Jolocom includes a "Ethereum Smart Contract" on the Rinkeby Testnet. Since The Merge however, the Rinkeby Testnet has been deprecated and removed.
To use the Jolocom connector, you will therefore need to deploy your own Smart Contract to act as the Verifiable Data Registry. This section describes one way of doing this.
- Setup a Wallet (for yourself, not an organisation)
- Download an Ethereum Wallet (MetaMask recommended, which works in-browser and is widely supported). Make sure to use and write down your seed phrase.
- Add the Sepolia Testnet to your Wallet by browsing
https://sepolia.dev/
and pressing "Add to MetaMask"
- Connect to a Blockchain Node (Provider). You can (in theory) run your own node, but its quickest and easiest to use a Blockhain Node Provider such as Alchemy:
- Create an account on
alchemy.com
- Create an App on
dashboard.alchemy.com
. Note down the API Key.
- Create an account on
- Deploy the Smart Contract
- Install Node v14
- The current project only works (as far as I can tell) with Node v14
- Installing an older Node version is most easily achieved using Node Version Manager
- i.e. using the command
nvm install lts/fermium
- Clone the repository
git clone jolocom/jolo-did-method
- Navigate to the contract package
cd packages/registry-contract
- Add the Sepolia Testnet to
truffle.config.js
:... const HDWalletProvider = require("@truffle/hdwallet-provider"); module.exports = { networks: { sepolia: { provider: () => { return new HDWalletProvider( "<YOUR WALLET SEED PHRASE / MNEMONIC", "https://eth-sepolia.g.alchemy.com/v2/<YOUR ALCHEMY API KEY>" ); }, network_id: 11155111, }, ... }, ... };
- Install dependencies
npm ci && npm install @truffle/hdwallet-provider && npm install --global truffle
- Deploy the contract on the Sepolia Testnet
trouble deploy --network sepolia
- Make sure to write down the address at which your contract is deployed
- Install Node v14
- Configure the backend to use your new smart contract
- Set the following environment variables
JOLOCOM_PROVDER_URL
withhttps://eth-sepolia.g.alchemy.com/v2/<YOUR ALCHEMY API KEY>
(if you opted to use Alchemy)JOLOCOM_CONTRACT_ADDRESS
with the address at which your contract is deployed
- If you are using
eassi-deployment
, set these in the.env
file
- Set the following environment variables
- Fix the leaky faucet
- Unfortunately, the default faucet used by the Jolocom library internally
is in need of a plumber (it was a Rinkeby faucet which is offline). The
backend repository includes a
helper.js.patch
file which alters thejolocom-lib
to wait for 60 seconds after creating a Wallet (generating its cryptographic keypair) before anchoring it on the blockchain (registering it to the registy smart contract, which requires ethereum/fuel). In these 60 seconds, you have the time to copy the Wallet address (see the console output) and send funds to it, so that the Wallet anchoring process can succeed. - The patch file can be applied as follows (assuming you currently reside in
the root of this repository):
patch -p1 < ./helper.js.patch
- Or perform this directly in the docker container (easier):
docker compose -f ./docker-compose.dev.yml run backend sh -c "path -p1 < ./helper.js.patch"
- Unfortunately, the default faucet used by the Jolocom library internally
is in need of a plumber (it was a Rinkeby faucet which is offline). The
backend repository includes a
Nest is MIT licensed.