Giter Site home page Giter Site logo

metamask / delegation-framework Goto Github PK

View Code? Open in Web Editor NEW
25.0 5.0 3.0 722 KB

The contracts that power the Delegation Framework

Home Page: https://metamask.io/developer/delegation-toolkit/

License: Apache License 2.0

Solidity 99.82% Shell 0.18%
4337 account-abstraction delegation metamask smart-wallet solidity web3

delegation-framework's Introduction

DeleGator Smart Account

A DeleGator Smart Account is a 4337-compatible Smart Account that implements delegation functionality. An end user will operate through a DeleGatorProxy which uses a chosen DeleGator implementation.

Overview

An end user controls a DeleGator Proxy that USES a DeleGator Implementation which IMPLEMENTS DeleGatorCore and interacts with a DelegationManager.

Delegations

A Delegation enables the ability to share the capability to invoke some onchain action entirely offchain in a secure manner. Caveats can be combined to create delegations with restricted functionality that users can extend, share or redeem.

A simple example is "Alice delegates the ability to use her USDC to Bob limiting the amount to 100 USDC".

Read more on "Delegations" ->

DeleGator

A DeleGator is the contract an end user controls and uses to interact with other contracts onchain. A DeleGator is an EIP-1967 proxy contract that uses a DeleGator Implementation which defines the granular details of how the DeleGator works. Users are free to migrate their DeleGator Implementation as their needs change.

DeleGator Core

The DeleGator Core includes the Delegation execution and ERC-4337 functionality to make the Smart Account work.

Read more on "DeleGator Core" ->

DeleGator Implementation

A DeleGator Implementation contains the logic for a DeleGator Smart Account. Each DeleGator Implementation must include the required methods for a DeleGator Smart Account, namely the signature scheme to be used for verifying access to control the contract. A few examples are the MultiSigDeleGator and the HybridDeleGator.

Read more on "MultiSig DeleGator" ->

Read more on "Hybrid DeleGator" ->

Delegation Manager

The Delegation Manager includes the logic for validating and executing Delegations.

Read more on "Delegation Manager" ->

Caveat Enforcers

Caveats are used to add restrictions and rules for Delegations. By default, a Delegation allows the delegate to make any onchain action so caveats are strongly recommended. They are managed by Caveat Enforcer contracts.

Developers can build new Caveat Enforcers for their own use cases, and the possibilities are endless. Developers can optimize their Delegations by making extremely specific and granular caveats for their individual use cases.

Read more on "Caveats" ->

Development

Third Party Developers

There's several touchpoints where developers may be using or extending a DeleGator Smart Account.

  • Developers can build custom DeleGator Implementations that use the DeleGator Core to create new ways for end users to control and manage their Smart Accounts.
  • Developers can write any contract that meets the DeleGator Core Interface to create novel ways of delegating functionality.
  • Developers can create custom Caveat Enforcers to refine the capabilities of a delegation for any use case they imagine.
  • Developers can craft Delegations to then share onchain capabilities entirely offchain.

Foundry

This repo uses Foundry.

Build

forge build

Test

forge test

Deploying

  1. Copy .env.example to .env and populate the variables you plan to use if you plan to deploy any contracts.
source .env
  1. Use Anvil to run a local fork of a blockchain to develop in an isolated environment.
anvil -f <your_rpc_url>
  1. Deploy the necessary environment contracts.

NOTE: As this system matures, this step will no longer be required for public chains where the DeleGator is in use.

forge script script/DeployEnvironmentSetUp.s.sol --rpc-url <your_rpc_url> --private-key $PRIVATE_KEY --broadcast

Javascript

Read more here.

Notes

  • We're building against solidity version 0.8.23 for the time being.
  • Format on save using the Forge formatter.

Style Guide

Read more on "Style Guide" ->

Relevant Documents

delegation-framework's People

Contributors

mcoso avatar dylandesrosier avatar

Stargazers

 avatar Alkhatri77 avatar Kevin Bluer avatar Tony Chen avatar debuggingfuture (Vincent LCY) avatar Idris Bowman avatar Elias Eldabbagh avatar Huawei avatar Corbin Page avatar Bruce Xu avatar Peter Pan avatar Julian Rachman avatar Timur Badretdinov avatar Paramet Kongjaroen avatar Pierrick Turelier avatar Vitor Marthendal Nunes avatar lakshmi kanth avatar Shun Kakinoki avatar Kames Geraghty avatar Tao Xu avatar meowy avatar  avatar Dan Finlay avatar  avatar  avatar

Watchers

Kevin Bluer avatar Harry avatar  avatar  avatar Alkhatri77 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.