Skip to main content

Issuer

GitHub repository

Requirements

  1. cargo, with rustc 1.74 or newer
  2. docker

Prepare environment

  1. Add the ABI source for generating contract bindings. This procedure is requested only when the contract definition changes. You just need to copy the artifacts/contracts/IDentity.sol/Identity.json ABI file in the smart-contracts directory. Abi sources are generated in the smart contracts repo.

  2. Create a .env file starting from .env.example and update the values accordingly to your development enviroment.

# Example from .env.example
# Rust flags
RUST_BACKTRACE=1
RUST_LOG=debug # minimum level of logging, also "info" is a possible value

# HTTP SERVER SETUP
HOST_ADDRESS=127.0.0.1 # "0.0.0.0" for deploying, "127.0.0.1" for dev
HOST_PORT=3213

# DLT CONFIG
NODE_URL="https://api.testnet.shimmer.network"
FAUCET_API_ENDPOINT="https://faucet.testnet.shimmer.network/api/enqueue"
RPC_PROVIDER="https://json-rpc.evm.testnet.shimmer.network"
CHAIN_ID=1073

# KEY STORAGE CONFIGURATION
KEY_STORAGE_STRONGHOLD_SNAPSHOT_PATH="./key_storage.stronghold"
KEY_STORAGE_STRONGHOLD_PASSWORD="some_hopefully_secure_password"
KEY_STORAGE_MNEMONIC="<key storage mnemonic>"

ISSUER_PRIVATE_KEY="<issuer_private_key>"
IDENTITY_SC_ADDRESS="<address of the Identity smart contract>"

# DATABASE CONNECTION CONFIG
DB_USER="<db_user>"
DB_PASSWORD="<db_password>"
DB_NAME="identity"
DB_HOST=<issuer db hostname> # "issuer-postgres" for deploying, "127.0.0.1 " for dev
DB_PORT=5432 # "5432" for deploying, "5433" for dev
DB_MAX_POOL_SIZE=16

Running the Application

  1. Start up the database by running:
docker compose --profile dev up -d
  1. Run the issuer service
# Run command in debug mode
cd server
cargo run --profile develop

Sometimes it may be useful to override .env parameters using cli args. The complete list of parameters is available typing the cargo run --profile develop -- --help command

For example, it is possible to define parameters for testing on different nodes:

cd server
# For local node Provider
cargo run --profile develop -- --rpc-provider "http://127.0.0.1:8545/" --chain-id 31337

# For Shimmer Provider
cargo run --profile develop -- --rpc-provider "https://json-rpc.evm.testnet.shimmer.network" --chain-id 1073

# For Sepolia
cargo run --profile develop -- --rpc-provider https://sepolia.infura.io/v3/<API_KEY> --chain-id 11155111

Run everything via Docker

Beware of the configuration of the environment variables. In addition, update the docker-compose.yaml accordingly.

Copy the smart contract json files to create the Rust bindings (mandatory if the smart contracts change. There is already a copy in this repo).

# assuming the mediterraneus-smart-contracts folder is located in the same root folder of mediterraneus-connector-rs
cp ../mediterraneus-smart-contracts/artifacts/contracts/Identity.sol/Identity.json ./smart-contracts

Commands to build the app’s container image and launch the app container:

docker compose --profile deploy up -d