Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: docker setup #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env_example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PRIVATE_KEY=
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
56 changes: 55 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,55 @@
# dkgcon-workshops-2024
# 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)
8 changes: 7 additions & 1 deletion create_knowledge_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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"]
11 changes: 11 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -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