|
1 |
| -## Foundry |
| 1 | +## Trusted Hint Registry |
2 | 2 |
|
3 |
| -**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.** |
| 3 | +This repository contains a smart contract for a registry of trusted hints used in decentralized ecosystems based on |
| 4 | +ERC-7506. It provides a standardized on-chain metadata management system aiding in verification of on- and off-chain |
| 5 | +data, like Verifiable Credentials. |
4 | 6 |
|
5 |
| -Foundry consists of: |
| 7 | +### Key Decisions |
6 | 8 |
|
7 |
| -- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools). |
8 |
| -- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data. |
9 |
| -- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network. |
10 |
| -- **Chisel**: Fast, utilitarian, and verbose solidity REPL. |
11 |
| - |
12 |
| -## Documentation |
13 |
| - |
14 |
| -https://book.getfoundry.sh/ |
| 9 | +- Upgradable smart contract using ERC1967 to enable future feature additions and bug fixes. |
| 10 | +- General purpose, access-controlled data structure usable by any address for hints. |
| 11 | +- Development, testing, and deployment is done via the Foundry toolset. |
| 12 | +- The deployments and ABI are provided via an NPM package from this repository. |
15 | 13 |
|
16 | 14 | ## Usage
|
17 | 15 |
|
18 | 16 | ### Build
|
19 | 17 |
|
20 | 18 | ```shell
|
21 |
| -$ forge build |
| 19 | +forge build |
22 | 20 | ```
|
23 | 21 |
|
24 | 22 | ### Test
|
25 | 23 |
|
26 | 24 | ```shell
|
27 |
| -$ forge test |
| 25 | +forge test |
28 | 26 | ```
|
29 | 27 |
|
30 |
| -### Format |
| 28 | +### Deploy |
31 | 29 |
|
32 | 30 | ```shell
|
33 |
| -$ forge fmt |
| 31 | +forge script DeployProxy --rpc-url <your_rpc_url> --private-key <your_private_key> --etherscan-api-key <your_etherscan_key> --verify --optimize --broadcast |
34 | 32 | ```
|
| 33 | +## Usage in other projects |
35 | 34 |
|
36 |
| -### Gas Snapshots |
| 35 | +### Install |
37 | 36 |
|
38 | 37 | ```shell
|
39 |
| -$ forge snapshot |
| 38 | +npm i @spherity/trusted-hint-registry |
40 | 39 | ```
|
41 | 40 |
|
42 |
| -### Anvil |
43 |
| - |
44 |
| -```shell |
45 |
| -$ anvil |
46 |
| -``` |
| 41 | +### Import |
47 | 42 |
|
48 |
| -### Deploy |
| 43 | +This package provides separate build for CommonJS and ES modules. You can import it in your project like this: |
49 | 44 |
|
50 |
| -```shell |
51 |
| -$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key> |
| 45 | +```typescript |
| 46 | +import { TRUSTED_HINT_REGISTRY_ABI, deployments } from "@spherity/trusted-hint-registry" |
52 | 47 | ```
|
53 | 48 |
|
54 |
| -### Cast |
55 |
| - |
56 |
| -```shell |
57 |
| -$ cast <subcommand> |
58 |
| -``` |
59 |
| - |
60 |
| -### Help |
61 |
| - |
62 |
| -```shell |
63 |
| -$ forge --help |
64 |
| -$ anvil --help |
65 |
| -$ cast --help |
66 |
| -``` |
| 49 | +In combination with, e.g., [viem](https://viem.sh/), you can use it like this: |
| 50 | + |
| 51 | +```typescript |
| 52 | +import { TRUSTED_HINT_REGISTRY_ABI, deployments } from "@spherity/trusted-hint-registry"; |
| 53 | +import { getContract } from 'viem' |
| 54 | + |
| 55 | +const publicClient = createPublicClient({ |
| 56 | + chain: sepolia, |
| 57 | + transport: http(), |
| 58 | +}) |
| 59 | + |
| 60 | +const sepoliaDeployment = deployments.find(d => d.chainId === 11155111 && d.type === "proxy") |
| 61 | +const contract = getContract({ |
| 62 | + address: sepoliaDeployment.registry, |
| 63 | + abi: TRUSTED_HINT_REGISTRY_ABI, |
| 64 | + publicClient, |
| 65 | +}) |
| 66 | + |
| 67 | +const namespace = "0x..." |
| 68 | +const list = "0x..." |
| 69 | +const key = "0x..." |
| 70 | +const hint = await contract.read.getHint(namespace, list, key) |
| 71 | +) |
0 commit comments