• Stars
    star
    1,173
  • Rank 39,852 (Top 0.8 %)
  • Language
    Solidity
  • License
    GNU Affero Genera...
  • Created almost 3 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple, intentionally-limited versions of web3 protocols & apps.

lil web3

Small, focused, utility-based smart contracts.

lil web3 aims to build really simple, intentionally-limited versions of web3 protocols & apps. By distilling them to their roots, we can better understand how they work.

lil ens

A stupidly-simple namespace implementation.

lil ens contains a single function register(string name), which allows an address to claim a name. \

The key learning here is that the technical implementation of a namespace can be incredibly simple, and its adoption (both of users and apps integrating with it) what makes it successful.

If you're interested in a slightly more comprehensive ENS-like implementation, I also built a simplified version of the base ENS contracts (and tests for them) following the ENS spec as a separate repo.

Contract Source β€’ Contract Tests

lil opensea

Barebones NFT marketplace.

lil opensea has three functions, allowing users to list their NFTs for sale (list(ERC721 tokenContract, uint256 tokenId, uint256 askPrice)), buy an NFT that has been listed (buyListing(uint256 listingId)), or cancel a listing (cancelListing(uint256 listingId)). These functions emit events (NewListing, ListingBought, and ListingRemoved) that could be picked up by a subgraph in order to build a database of available listings to present in a UI.

Note: Remember to call setApprovalForAll(<lil opensea address>, true) on the contract for the NFT you're listing before calling the list function πŸ˜‰

Contract Source β€’ Contract Tests

lil fractional

Barebones NFT fractionalisation factory.

lil fractional contains a split(ERC721 nftContract, uint256 tokenId, uint256 supply, string name, string symbol) function you can call to fractionalise your NFT into any amount of $SYMBOL ERC20 tokens (leaving the sale/spread of these at the discretion of the caller), and a join(uint256 vaultId) that you can call if you own the entirety of the $SYMBOL supply to burn your tokens and get the NFT back.

Note: Remember to call setApprovalForAll(<lil fractional address>, true) on the contract for the NFT you're fractionalising before calling the split function, and to call approve(<lil fractional address>, <supply or greater>) on the contract for the ERC20 before calling the join function πŸ˜‰

Contract Source β€’ Contract Tests

lil juicebox

Very simple token sale + refund manager.

lil juicebox allows users to participate in a fundraising campaign by sending ETH via the contribute() function, in exchange for a proportional share of ERC20 tokens, until the owner decides to close the campaign (setState(State.CLOSED)) and withdraw the funds (calling withdraw()). If the owner decides to issue refunds (setState(State.REFUNDING)) they can send all the ETH back to the contract, where users can burn their ERC20 tokens to get back their ETH (using refund(uint256 amount)). Finally, the owner can renounce ownership of the campaign (making it impossible to change any of the aforementioned settings) by calling renounce().

Note: Remember to call approve(<lil juicebox address>, <amount of tokens to refund>) on the contract for the ERC20 before calling the refund function πŸ˜‰

Contract Source β€’ Contract Tests

lil flashloan

A (Proof of Concept)-level flash loan implementation

lil flashloan allows contract implementing the onFlashLoan(ERC20 token, uint256 amount, bytes data) to temporarily receive any amount of ERC20 tokens (limited by the loaner's supply ofc), by calling the execute(FlashBorrower receiver, ERC20 token, uint256 amount, bytes data) function. These tokens should be repaid (along with any fees) before the end of the transaction to prevent it from reverting. The owner of the contract can set a fee percentage for any ERC20 by calling setFees(ERC20 token, uint256 fee) (fee is a percentage multiplied by 100 to avoid decimals, 10_00 would be 10% for example), and can withdraw the contract's balance by calling withdraw(ERC20 token, uint256 amount).

Note: In order to keep the contract simple, it's not compliant with EIP-3156 (the flash loan standard).

Contract Source β€’ Contract Tests

lil gnosis

An optimised ERC721-based multisig implementation

lil gnosis allows you to define a set of approved signers and the number of required signatures to execute a transaction (or change the configuration params) when deploying the contract LilGnosis(string name, address[] signers, uint256 quorum). Once deployed, signers can craft EIP-712 signatures (using the Execute(address target,uint256 value,bytes payload,uint256 nonce) signature) to execute any transaction by calling the execute(address target, uint256 value, bytes payload, Signature[] signatures) function. You can also update the number of required signatures by calling the setQuorum(uint256 quorum, Signature[] sigs) function, or add and remove trusted signers by calling setSigner(address signer, bool shouldTrust, Signature[] sigs).

Note: For implementation reasons, when building the array of signatures, you need to order them in ascending order by the address that signed them. If you don't do this, the verification will fail!

Contract Source β€’ Contract Tests

lil superfluid

A simple token streaming implementation

lil superfluid enables anyone to continuously stream tokens to a user during an interval of blocks. You can call the streamTo(address recipient, ERC20 token, uint256 initialBalance, Timeframe timeframe, uint256 paymentPerBlock) function to send paymentPerBlock every block the stream is active for (between by timeframe.startBlock and timeframe.stopBlock) to recipient, locking initialBalance tokens to guarantee their delivery. Once created, the sender can increase the locked balance by calling the refuel(uint256 streamId, uint256 amount) function, and the receiver can withdraw their current balance at any time by calling withdraw(uint256 streamId). Once the stream has ended, the sender can call refund(uint256 streamId) to withdraw any excess locked funds, and at any point any party can view their balance through balanceOf(uint256 streamId, address who), or update the stream rate or timeframe through by providing an EIP-712 signature from the other party (certifying they approve of it) to the updateDetails(uint256 streamId, uint256 paymentPerBlock, Timeframe timeframe, Signature sig) function.

Note: Remember to call approve(<lil superfluid address>, <amount>) on the contract for the ERC20 before calling the streamTo and refuel functions πŸ˜‰

Contract Source β€’ Contract Tests

Contributing

Part of the motivation behind lil web3 is to get better at Solidity. For this reason, I won't be accepting PRs that add new lil contracts, as I'd rather implement them myself.

That doesn't mean contributions aren't welcome tho! If you find a bug, gas optimisation, or there's something you'd have written differently, a PR will be very appreciated. New ideas for protocols/apps you'd like to see me try to build are also very welcome!

License

This project is open-sourced software licensed under the GNU Affero GPL v3.0 license. See the License file for more information.

More Repositories

1

chatgpt-telegram

Run your own GPTChat Telegram bot, with a single command!
Go
3,871
star
2

plz-cli

Copilot for your terminal
Rust
1,574
star
3

yt-whisper

Using OpenAI's Whisper to automatically generate YouTube subtitles
Python
1,327
star
4

auto-subtitle

Automatically generate and overlay subtitles for any video.
Python
1,259
star
5

auto-commit

A CLI tool that automatically writes commit messages for you.
Rust
1,182
star
6

laravel-fastlogin

Allow your users to login with FaceID/TouchID
PHP
962
star
7

browser-agent

A browser AI agent, using GPT-4
Rust
664
star
8

dapp-starter

The template I use to kickstart all my web3 apps.
TypeScript
395
star
9

armchair

A Next.js template with everthing your web3 app needs.
TypeScript
378
star
10

tinyvector

A tiny embedding database in pure Rust.
Rust
343
star
11

threads-re

Reverse-engineering Instagram's Threads private APIs.
316
star
12

chatgpt-discord

Run your own GPTChat Discord bot, with a single command!
Go
292
star
13

commit

Command palette-style Git client for blazing-fast commits.
Rust
243
star
14

mirror-next

A Next.js-powered frontend for your Mirror publication
TypeScript
142
star
15

Tasks

Simple tasks & notes manager written in PHP, jQuery and Bootstrap using a custom flat file database.
PHP
107
star
16

nft-token-drop

A drop-in contract to airdrop all current holders of an NFT with an ERC20 token
Solidity
106
star
17

cog-rust

Rust containers for machine learning.
Rust
103
star
18

laravel-web3-login

Allow your users to login with their Ethereum wallet.
PHP
102
star
19

whisper-cli-rs

A Whisper CLI, built with Rust.
Rust
91
star
20

proof-of-kyc

An NFT that proves you've gone through an identity verification process, powered by Stripe Identity.
TypeScript
87
star
21

clippy-widget

An AI-powered assistant for your company's docs.
TypeScript
75
star
22

threads-api

Reverse-engineered Rust client for Instagram's Threads app.
Rust
74
star
23

refract

A Hacker News style forum, built on the Lens Protocol.
TypeScript
66
star
24

erc721-drop

A simple ERC721 drop implementation, using Forge and Solmate.
Solidity
64
star
25

ray-js

JavaScript
57
star
26

connect4-sol

An optimised Connect4 game implementation on Solidity
Solidity
51
star
27

Activity

A PHP API to log anything anywhere
PHP
48
star
28

support_center

Support center made with Laravel
PHP
47
star
29

textos-twitter

Swift
47
star
30

better-pest

A better Pest test runner for VS Code
JavaScript
45
star
31

cog-nsfw-filter

Run any image through the Stable Diffusion content filter
Python
44
star
32

laravel-apple-login

Plug-and-play Sign in with Apple for Laravel
PHP
42
star
33

lil-docker

An intentionally-limited Rust implementation of the Docker runtime with no external dependencies.
Rust
41
star
34

nextjs13-connectkit-siwe

Using ConnectKit's SIWE with the Next.js v13 App Router
TypeScript
40
star
35

laravel-multiformat

Multiformat Endpoints in Laravel
PHP
39
star
36

send-to-things

A PWA to add tasks to Things from pretty much anywhere
JavaScript
39
star
37

lil-redis

An intentionally-limited Rust implementation of the Redis server with no external dependencies.
Rust
38
star
38

ai-code

copilot, but worse
TypeScript
36
star
39

laravel-fun

A fun package that registers a few routes bots usually search for, and gives them a nice surprise instead.
PHP
36
star
40

zorb-fridge

Zorbs shift when transferred. The Zorb Fridge allows you to freeze them.
Solidity
33
star
41

lens-leaderboard

A leaderboard using 100% public data to rank notable profiles on the Lens Protocol.
TypeScript
32
star
42

lumiere

Web3 video platform, powered by the Lens Protocol.
TypeScript
31
star
43

soulminter-contracts

A barebones contract to easily mint Soulbound NFTs
Solidity
30
star
44

php-evm

"lol. lmao" - m1guelpf.eth
PHP
29
star
45

roam-app

An iOS app for Roam Research
Swift
27
star
46

dyson

Your self-hosted ML model interface
Rust
27
star
47

lil-http-rs

A Rust web framework with no external dependencies
Rust
26
star
48

ensemble

A Laravel-inspired ORM for Rust
Rust
26
star
49

swift-realtime-openai

A modern Swift SDK for OpenAI's Realtime API
Swift
26
star
50

repair-json

Repair incomplete JSON (e.g. from streaming APIs or AI models) so it can be parsed as it's received.
Rust
26
star
51

dollar-auction.sol

A dollar auction implementation in Solidity.
Solidity
24
star
52

flysystem

A filesystem abstraction layer for Rust.
Rust
24
star
53

amnesia

An expressive Rust library for interacting with a cache.
Rust
24
star
54

solserve

An experimental Solidity-based web framework
TypeScript
23
star
55

wagmipet-frontend

An on-chain tamagotchi-inspired game, with metratransactions and social login.
TypeScript
22
star
56

ens-contracts-blindrun

For Solidity practice, I tried to rebuild the base ENS contracts from the EIP-137.
Solidity
20
star
57

silhouette

A simple dependency injection library for Rust
Rust
20
star
58

wallet-activity

User-friendly Ethereum transaction descriptions.
TypeScript
19
star
59

soulminter

One-click mint for Soulbound NFTs on Ethereum, Optimism & Polygon.
TypeScript
19
star
60

wagmipet-contracts

Solidity
19
star
61

dapp-browser

A simple, ENS-powered browser for Ethereum dApps
JavaScript
19
star
62

mute.guru

Take back your twitter feed, by instantly muting all engagement farmers.
TypeScript
19
star
63

ghost-heroku

Deploy Ghost to Heroku (with storage)
JavaScript
18
star
64

necromint

An ERC721 for resurrecting the dead.
Solidity
17
star
65

obs-now-playing

Let your listeners know what music you're playing right now by showing it on screen at all times!
JavaScript
17
star
66

indigo

A simple interface for speaking with AI assistants. Inspired by OpenAI's DevDay Keynote.
Swift
17
star
67

walletconnect-extension

JavaScript
16
star
68

website-theme

The Ghost theme that powers my website
JavaScript
16
star
69

epicenter

Simple sync/async event dispatcher for Rust
Rust
14
star
70

lens-embeds

One-click embeds for all your links posts, mirrors & comments.
TypeScript
12
star
71

m1guelpf

11
star
72

redeez-rs

A simplified general-purpose queueing system for Rust apps.
Rust
11
star
73

weekday-nft

An experiment in generative NFTs that tells you the current day of the week.
JavaScript
11
star
74

rainbow-bridge-ios

An iOS Safari extension that redirects MetaMask calls to Rainbow.
Swift
11
star
75

cog-whisper

OpenAI Whisper as a Cog model
Python
11
star
76

LicAPI

A PHP API to manage license info
PHP
11
star
77

formtato

A lil web3 form for Ana's potato comissions
TypeScript
10
star
78

things-newtab

Your Things tasks on every tab
Vue
9
star
79

native-collection

Adding Collection functions to the PHP array scalar type
PHP
9
star
80

proof-of-love

Refactoring of a simple smart contract for Leah
Solidity
9
star
81

clippy

AI-powered assistant for your company's docs
Rust
9
star
82

prompt-organizer

A simple library to better manage AI prompts in your Rust code.
Rust
9
star
83

php-ghost-api

A PHP API client for the Ghost v2 Content API
PHP
8
star
84

aranet-rs

Read air quality data from an Aranet4 device in Rust
Rust
8
star
85

laravel-ssl

A Laravel package to enforce HTTPS
PHP
7
star
86

nouns-dataset

A HuggingFace text-to-image dataset for Nouns
TypeScript
7
star
87

readme-with-video

An example of a repo with a video on its README
7
star
88

ens-delegatoor

A lil website that shows who you've delegated your $ENS to.
TypeScript
7
star
89

laragit

A Laravel interface for managing Github notifications.
PHP
7
star
90

procreate-rs

A simple library for parsing Procreate files in Rust.
Rust
7
star
91

bambulab-rs

An unofficial API client for Bambu Lab's Cloud API
Rust
7
star
92

laravel-feature

Feature toggling for Laravel
PHP
6
star
93

pingcrm-rs

A demo application to illustrate an Axum + Inertia.js workflow.
Rust
6
star
94

swift-wallet-bridge

A Swift implementation of Worldcoin's end-to-end encrypted ZKP bridge
Swift
6
star
95

book-story

An original book-reading experience powered by AMP Stories
HTML
6
star
96

axum-signed-urls

Signed URL middleware for Axum, using extractors.
Rust
5
star
97

wc-playground

Playing around with WalletConnect v2
TypeScript
5
star
98

eloquent-immutable

Enforce table immutability using Laravel Eloquent
PHP
5
star
99

lens-garden

Links only your Lens followers can access.
TypeScript
5
star
100

lens-hotlink

Lens Protocol links that open with your preferred frontend
TypeScript
5
star