Skip to content

PJUllrich/Ethereum-Workshop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ethereum Workshop

This is an introductory workshop for how to develop Ethereum smart contracts with Python3. The popular Python library Populus will be used to test and deploy smart contracts. Smart contracts are generally written in Solidity which is a programming language specifically developed to run on the Ethereum Virtual Machine.

Getting Started

  1. Clone this project into a new folder on your machine
  2. Install all System Dependencies, which are stated in this article
  3. Install the Solidity Compiler as explained in this article
  4. Create a new Virtual Environment with Python 3.5 or later. This article explains how.
  5. Activate your Virtual Environment as described in the article.
  6. Install all requirements with pip install -r requirements.txt
  7. Run populus compile. You should the compiled contract in the folder /build
  8. Run the tests with py.test tests.

How to run the project

  1. Run the local chain with testrpc --seed 0
  2. Run Django server with python manage.py runserver
  3. In your browser, go to http://localhost:8000
  4. Open the Inspector in your browser. Here's how to do that in Chrome or Firefox.
  5. Go to Console in the Inspector. You should see some info about what's happening.

Where to write your functionality

  • Any Smart Contract functionality can be written into contracts/ICO.sol
    • After you wrote your functionality, run populus compile
    • Then add the abi value from build/contracts.json to the contractABI in website/ico/static/js/index.js
    • Add the bytecode value from build/contracts.json to the contractBytecode, also in website/ico/static/js/index.js
  • Any Frontend functionality can be written into website/ico/static/js/index.js
    • Once you added your functionality, just refresh your website at localhost:8000.
    • I recommend to access the website in the Incognito mode of your browser. This way, your browser won't load the website from cache, but take it from your project.

Challenges

The goal of the workshop is to get an understanding of how to write and deploy Smart Contracts. Once you have the project up and running, you can try to extend the Smart Contract with either your own functionality, or alternatively, you can pick from one of these challenges:

  • Add a maximum amount of coins that buyers can buy
    • Think about what message you send when that amount is reached and how you send it.
  • Add discounts for buying coins
    • Buyers could get a 50% discount for the first 10.000 coins, 40% for the next 10.000 and so on.
  • Add a refund function
    • Think about who should be able to call this function (probably only the owner)
    • Will all coins be refunded or only a part?
    • Advanced: Add a time frame in which a refund can be requested. Buyers are not able to request a refund after that time frame expired.
  • Add functionality that can only be executed using the coins
    • Like a Voting function, or requesting a funny message

Resources

Here are some links to interesting resources about Ethereum and Smart Contracts

About

Python Workshop about Ethereum and Smart Contracts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published