Welcome to the DeFi Safety Workshop on Timelock Encryption! This repository contains all the resources, code, and materials needed for a hands-on developer workshop focused on improving security in decentralized finance (DeFi) using timelock encryption. Timelock encryption enables data to be encrypted and decrypted only after a specified time period or condition is met. This approach is valuable for delaying access to sensitive information, securing transactions, and mitigating front-running attacks.
- About the Workshop
- Prerequisites
- Setup Instructions
- Workshop Agenda
- Learning Objectives
- Resources
- Contributing
- License
In this workshop, we explore how the security of smart contracts and DeFi applications can be enhanced using timelock encryption.
Participants will:
- Learn the fundamentals of timelock encryption and its applications in DeFi. It is worth mentioning that this differs from Timelock smart contracts, also known as time-based or delayed contracts, which are a specialized type of smart contract that introduces a delay or time-based constraint on the execution of certain actions or transactions.
- Understand the potential vulnerabilities that timelock encryption addresses to enhance the security of DeFi protocols.
- Implement a simple smart contract that incorporates timelock functionalities.
- Introduction to Timelock Encryption
- An introduction to timelock encryption:
- What is it?
- Features
- Use cases
- An introduction to timelock encryption:
- Enhancing Security in DeFi with Timelock Encryption
- Overview of use cases in DeFi (e.g., securing auctions, sealed bids, delayed transactions, securing governance actions relating to lending parameters, securing staking reward distribution information, among others).
- Hands-On Exercise: Simple Auction Smart Contract with Sealed Bids Secured by Timelock Encryption
- Q&A and Wrap-Up
By the end of the workshop, participants will be able to:
- Understand the principles and benefits of timelock encryption in DeFi.
- Implement and deploy Solidity smart contracts with timelock functionality.
Before getting started, ensure you have the following tools installed:
-
Docker: Make sure Docker is installed on your system. You can download Docker from Docker's official website.
-
Docker Compose: Docker Compose is usually included with Docker Desktop installations. To verify its installation, run the following command:
docker compose version
Follow these steps to set up your local environment for the workshop:
-
Clone the Repository
git clone https://github.com/randa-mu/devcon-2024-timelock-workshop.git cd devcon-2024-timelock-workshop
-
Start Services Using Docker Compose: The
docker-compose.yml
file defines all the services that are required to run the project. To start these services in detached mode (background), run the following command:docker compose up -d
Docker Compose will automatically: - Create all required images. - Build the services as needed. - Set up networks and containers.
-
Verify Running Containers To check that all services are running correctly, use:
docker compose ps
This will show a list of all containers and their current status. Ensure that each service defined in
docker-compose.yml
is listed and is running.
Once you've verified that all the required services are up and running, please follow the step-by-step guide provided for the hands-on exercise.
Here are some helpful resources for further reading:
- Timelock Encryption On-Chain
- Ethereum Smart Contract Best Practices
- Foundry Documentation
- Solidity Documentation
- OpenZeppelin Contracts Library
Contributions are welcome! If you have any suggestions or improvements for the workshop, feel free to submit a pull request or open an issue.
- Fork the repository.
- Clone your forked repository to your local machine.
- Create a new branch:
git checkout -b feature/your-feature-name
. - Commit your changes:
git commit -m 'Add some feature'
. - Push to the branch:
git push origin feature/your-feature-name
. - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.