Ver código fonte

basically hello world

tarfeef101 3 anos atrás
commit
336a5a3de8
5 arquivos alterados com 37 adições e 0 exclusões
  1. 9 0
      README.md
  2. 7 0
      src/app/Dockerfile
  3. 9 0
      src/app/app.py
  4. 2 0
      src/app/requirements.txt
  5. 10 0
      src/docker-compose.yaml

+ 9 - 0
README.md

@@ -0,0 +1,9 @@
+# Purpose
+Just a test playground to try my hand at coding on ethereum, doesn't do anything specific yet
+
+# Usage
+- `docker-compose up -d client_test` to start the test chain
+- `docker-compose run app` for now to run the client (not a persistent service)
+
+# Issues
+- Cannot upgrade to `python3.10` due to `cytoolz` (a dependency of `web3`) not being compatible yet

+ 7 - 0
src/app/Dockerfile

@@ -0,0 +1,7 @@
+FROM python:3.9-alpine
+COPY requirements.txt /opt
+WORKDIR /opt
+RUN apk add gcc musl-dev
+RUN python3 -m pip install -r requirements.txt
+COPY app.py /opt
+CMD ["python", "app.py"]

+ 9 - 0
src/app/app.py

@@ -0,0 +1,9 @@
+from web3 import Web3 as eth
+
+# gwei
+wallet=6478810
+print("I own", eth.fromWei(eth.toWei(wallet, 'gwei'), 'ether'), "ether.")
+
+# ganache testing
+chain = eth(eth.HTTPProvider('http://client_test:8545'))
+print(chain.isConnected())

+ 2 - 0
src/app/requirements.txt

@@ -0,0 +1,2 @@
+web3 ~= 5.24.0
+requests ~= 2.26.0

+ 10 - 0
src/docker-compose.yaml

@@ -0,0 +1,10 @@
+version: '3'
+
+services:
+  app:
+    build: ./app
+    container_name: ethtest
+    image: tarfeef101/ethtest
+    #  client:
+  client_test:
+    image: trufflesuite/ganache-cli:latest