diff --git a/.env_example b/.env_example new file mode 100644 index 0000000..6fc16b3 --- /dev/null +++ b/.env_example @@ -0,0 +1 @@ +PRIVATE_KEY= diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2a17e21 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM python:3.11-slim-buster + +WORKDIR /workshop + +# prevent generation of .pyc files +ENV PYTHONDONTWRITEBYTECODE 1 +# turn of buffering for easier container logging +ENV PYTHONUNBUFFERED 1 + +COPY . /workshop/ + +RUN apt-get update && \ + apt-get install -y vim +# RUN /workshop/install.sh + +EXPOSE 8900 9000 diff --git a/README.md b/README.md index 96b834a..43335c5 100644 --- a/README.md +++ b/README.md @@ -1 +1,55 @@ -# dkgcon-workshops-2024 \ No newline at end of file +# dkgcon-workshops-2024 + +[Workshop Slides](https://docs.google.com/document/d/1MtFpaZypd1eg5AcSir1B9VAZSLTUelITGUX3U27wyPk/edit) + +## Setup + +* Clone repo +```bash +git clone https://github.com/OriginTrail/dkgcon-workshops-2024 +cd dkgcon-workshops-2024 +``` +* Generate .env file +``` +cp .env_example .env +``` +* Create EVM wallet and save it privately and securely. +* Add Base Sepolia network to Metamask or similar https://docs.base.org/docs/using-base/#testnet +* Request Base Sepolia Testnet tokens from the faucet for the public address of your wallet https://docs.base.org/docs/tools/network-faucets/ +* Add private key to .env file +* Run Docker container in detached mode +```bash +docker-compose up --build workshop -d +docker ps -a +``` +* Enter Docker container +``` +docker exec --workdir /workshop -it workshop-workshop-1 /bin/bash +``` + +* Optional: View Docker container logs +``` +docker-compose logs --tail=1000 -f workshop +``` + +## Exercise 1: Create Knowledge Asset + +* Run Python script inside the Docker container +```bash +python3 create_knowledge_asset.py +``` + +* View transaction on Base Sepolia block explorer https://sepolia-explorer.base.org + +## Exercise 2: Transfer Asset + +Try to +``` +new_owner = "0x" +ual = "did" +assert_transfer_result - dkg.asset.transfer(ual, new_owner) +``` + +## Resources: + +[DKG.py Client](https://docs.origintrail.io/dkg-v8-upcoming-version/v8-dkg-sdk/dkg-v8-py-client) diff --git a/create_knowledge_asset.py b/create_knowledge_asset.py index 2d627ce..3e74dea 100644 --- a/create_knowledge_asset.py +++ b/create_knowledge_asset.py @@ -78,7 +78,13 @@ def print_json(json_dict: dict): print_json(info_result) divider() -create_asset_result = dkg.asset.create(content, 2) +# epochs are measured as 1 epochs = 3 months for incentivised storage +# of knowledge assets + +# optionally provide token amount to lock to store on more nodes +epochs = 2 +token_amount = 0 +create_asset_result = dkg.asset.create(content, epochs, token_amount) print("======================== ASSET CREATED") print_json(create_asset_result) divider() diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..993b2c0 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: "3" +name: workshop +services: + workshop: + build: . + tty: true + ports: + - "8545:8545" + - "8900:8900" + - "9000:9000" + entrypoint: ["tail", "-f", "/dev/null"] diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..d86b293 --- /dev/null +++ b/install.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# install dependencies +pip install python-dotenv +pip install --upgrade pip + +# install Python >= 3.1 +# create and activate virtual environment +python3 -m venv venv +source venv/bin/activate +pip install -r requirements.txt