Skip to content

A reference implementation of EIP-2535: The Diamond Standard using TypeScript and TypeChain.

License

Notifications You must be signed in to change notification settings

erhant/diamonds-with-typescript

Repository files navigation

Diamonds with TypeScript

This repository has implementations and tests for EIP-2535: Diamond Standard in TypeScript. It uses TypeChain and shows a neat way to call facets via casting:

//    contract variable                         facet name     diamond address     cast to contract type
const foobarFacet = (await ethers.getContractAt('FoobarFacet', diamondAddress)) as FoobarFacet;

Although you are connected to the Diamond contract, the calldata will be formed according to FoobardFacet which will cause them to fall into the fallback at the diamond, and be routed accordingly.

This repository is complementary to my blog post: https://dev.to/erhant/how-to-use-typescript-with-eip-2535-diamonds-3gl6

Usage

  • yarn to install the required packages.
  • yarn compile to compile the contracts.
  • yarn test to test the contracts.
  • yarn lint to lint everything.
  • yarn clean to clean build artifacts.
  • yarn node:start to start a Hardhat node on localhost.
  • yarn node:run <path> to run a script at the given path on localhost.

Formatting & Linting

About

A reference implementation of EIP-2535: The Diamond Standard using TypeScript and TypeChain.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published