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
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 onlocalhost
.yarn node:run <path>
to run a script at the given path onlocalhost
.
- TypeScript codes are formatted & linted with GTS.
- Contracts are formatted with Solidity + Hardhat.