https://github.com/erhant/diamonds-with-typescript
A reference implementation of EIP-2535: The Diamond Standard using TypeScript and TypeChain.
https://github.com/erhant/diamonds-with-typescript
diamond ethereum typechain typescript
Last synced: 28 days ago
JSON representation
A reference implementation of EIP-2535: The Diamond Standard using TypeScript and TypeChain.
- Host: GitHub
- URL: https://github.com/erhant/diamonds-with-typescript
- Owner: erhant
- License: mit
- Created: 2022-12-02T08:10:11.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-12-04T19:54:21.000Z (over 3 years ago)
- Last Synced: 2025-01-13T06:43:20.533Z (over 1 year ago)
- Topics: diamond, ethereum, typechain, typescript
- Language: Solidity
- Homepage:
- Size: 23.4 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Diamonds with TypeScript
This repository has implementations and tests for [EIP-2535: Diamond Standard](https://eips.ethereum.org/EIPS/eip-2535) in TypeScript. It uses TypeChain and shows a neat way to call facets via casting:
```typescript
// 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:
## 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 ` to run a script at the given path on `localhost`.
## Formatting & Linting
- TypeScript codes are formatted & linted with [GTS](https://github.com/google/gts).
- Contracts are formatted with [Solidity + Hardhat](https://hardhat.org/hardhat-vscode/docs/formatting).