Skip to content

ENS bound non-transferrable on-chain badges implemented for ETHIndia'22. Won multiple sponsor prizes πŸ†

License

Notifications You must be signed in to change notification settings

PraneshASP/ens-bound-badges

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

27 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ENSBoundBadges β€’ license solidity

UPDATE: This project was built in less than 12 hours for ETHIndia'22 and won multiple prizes from sponsors πŸŽ‰

ethindia-22

A permission-less and a fully-decentralized system that allows anyone to issue on-chain badges that'll be tied forever to the user's ENS domain. See project submission here in Devfolio.

Warning

These contracts are unaudited and are not recommended for use in production. Due to time constraints, there are no automated tests available yet, the system is MANUALLY TESTED as of now.

This is experimental software and is provided on an "as is" and "as available" basis. There are no warranties and we will not be liable for any loss incurred through any use of this codebase.

What?

Inspired by Vitalik's blog on Soulbound token, I wanted to build something cool and interesting for ETHIndia'22 hackathon.

For those who don't know:

A soulbound item, once picked up, cannot be transferred or sold to another account.While transferable NFTs have their place and can be really valuable on their own for supporting artists and charities, there is also a large and underexplored design space of what non-transferable NFTs could become.

So I ended up building this ENSBoundBadge protocol. The system is completely permissionless such that anyone could issue their own badges on-chain with their own icons (passed as BadgeInfo) for any purpose, it could be issued for hackathon winners, for bug bounty hunters, for CTF Challenge solvers, for gas optmizooors and for anyone they want. And the cool part is whenever a new badge is issued or revoked, the address associated with the ENS will receive a push notification via Push protocol and Graph protocol integration!

Why?

  • Fully decentralized and permissionless - Anyone can issue new ENSBoundBadges
  • Customizable badges via BadgeInfo struct.
  • Subgraph dynamic indexing of newly created ENSBoundBadge contracts via factory
  • Efficient deployment of ENSBoundBadge contract via Minimal proxies.
  • Since the Subgraph is configured, frontend can seamlessly fetch and render badges
  • Push notifications via Push protocol.
  • And more...

System Overview:

image

Smartcontracts Overview:

From the above architecture diagram, you can see there are a couple of important contracts.

  • ENSBoundBadge: This is the core contract that's used to issue or revoke badges. It is ERC721 compatible but cannot be transferred. For every event, a new ENSBoundBadge contract has to be deployed. For example, we cannot use the same ENSBoundBadge contract for both ETHIndia hackathon and Paradigm's CTF contest. There should be a new collection deployed for different occasions. This is the contract that also interacts with the ENS contracts to resolve domain names.

  • ENSBoundBadgeFactory: This is a factory contract that is used to deploy (clone) the ENSBoundBadge contract. This contract uses EIP-1167 (Minimal proxy) standard to create new ENSBoundBadge contracts saving gas fees on deployment.


Since I was hacking alone and due to limited time, there was no frontend for this app yet. But the contracts and subgraph are deployed and verified on Goerli testnet for you guys to try it out.

Component Link
ENSBoundBadgeFactory https://goerli.etherscan.io/address/0x2A89C6fC204124924fB860aacdb51BaE9686F8f7
ENSBoundBadge (Implementation) https://goerli.etherscan.io/address/0xd15B5D3D12AFAEb2cb2211E1449aC2860fD7D55D
Subgraph https://thegraph.com/hosted-service/subgraph/praneshasp/ensboundbadge-test
EPNS Channel https://staging.push.org/#/channels?channel=0x18d0daD1839a26FE6d5718791BAf4e7bC12b49eC

As the app is currently on goerli testnet, there's no ENS Support for Mumbai testnet hence we cannot try this app out. Hence I chose goerli. But for mainnet deployment we'll probably have fully on-chain rendered badges for which we'll use Polygon.

Here are some quick screenshots of the push notifications received.

  • When a badge is issued:

  • When a badge is revoked:

Getting Started

Requirements

The following will need to be installed in order to use this repo. Please follow the links and instructions.

  • Git
    • You'll know you've done it right if you can run git --version
  • Foundry / Foundryup
    • This will install forge, cast, and anvil
    • You can test you've installed them right by running forge --version and get an output like: forge 0.2.0 (f016135 2022-07-04T00:15:02.930499Z)
    • To get the latest of each, just run foundryup

Quickstart

  1. Clone this repo:
git clone https://github.com/PraneshASP/ens-bound-badges
cd ens-bound-badges
  1. Install dependencies

Once you've cloned and entered into your repository, you need to install the necessary dependencies. In order to do so, simply run:

forge install
  1. Build

To build your contracts, you can run:

forge build
  1. Deployment

Create a .env file and copy the contents of .env.examples to it. Update the fields with relavant values.

To proceed with the deployment, run the following command...

source .env

forge script scripts/Deploy.s.sol:Deploy --fork-url $POLYGON_INFURA_RPC_URL --private-key $PRIVATE_KEY --broadcast

For more information on how to use Foundry, check out the Foundry Github Repository.

Blueprint

scripts
β”œβ”€ Deploy.s.sol β€” Deployment Script
src
β”œβ”€interfaces
|    β”œβ”€ IENSBoundBadge.sol - The ENSBoundBadge token interface
|    └─ IENS.sol - Interface containing methods to resolve ENS domain names.
β”œβ”€ ENSBoundBadge.sol β€” The ENSBoundBadge token contract
β”œβ”€ ENSBoundBadgeFactory.sol - Factory contract to deploy new badge contracts
β”œβ”€ ERC721Initializable.sol - Modified ERC721 contract from solmate to support Clones.
|
subgraph
    β”œβ”€ abis - ENSBoundBadge and factory contract ABI for the Subgraph schema and mappings
    β”œβ”€ src - Contains mapping and other helper methods for EPNS integration
    β”œβ”€ schema.graphql - Contains all the entity definitions
    └─ subgraph.yaml - Includes templates and data sources for indexing

License

MIT

Next Steps

  • Add unit tests and integration tests
  • Build frontend/UI/CLI
  • Improve subgraph - Add more entities
  • Fully on-chain badges?
  • Integrate with other ID services like UnstoppableDomains, etc.,

Disclaimer

These smart contracts are being provided as is. No guarantee, representation or warranty is being made, express or implied, as to the safety or correctness of the user interface or the smart contracts. They have not been audited and as such there can be no assurance they will work as intended, and users may experience delays, failures, errors, omissions, loss of transmitted information or loss of funds. The creators are not liable for any of the foregoing. Users should proceed with caution and use at their own risk.

About

ENS bound non-transferrable on-chain badges implemented for ETHIndia'22. Won multiple sponsor prizes πŸ†

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published