An open API service indexing awesome lists of open source software.

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.

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).