Implementation of the Farcaster ID Registry and Farcaster Name Registry contracts specified in the Farcaster protocol. The contracts are built with Foundry, a modular toolkit for developing Ethereum contracts. Please see the documentation for more details about the contracts.
First, ensure that the following are installed globally on your machine:
Then, from the project root, run yarn install
to install NPM dependencies. Once this is done you can run forge build
and forge test
to verify that everything is set up correctly.
yarn lint
uses Prettier Solidity to find and auto-correct common problems.yarn lint:check
performs the same checks, but alerts on errors and does not fix them.
Code follows the Solidity style guide and documentation follows Ethereum Natspec unless otherwise specified. If you use VS Code, you can lint-on-save by installing the Solidity and ESLint extensions.
ID Registry Deployment Addresses:
Network | Address |
---|---|
Rinkeby | 0x0a632c23d86ed99daf4450a2c7cfc426b23781d9 |
A new instance of the contract can be deploying by using forge to execute the deployment script. To do this, create a .env
file with the following secrets:
RINKEBY_RPC_URL
- get this from alchemy or infuraRINKEBY_PRIVATE_KEY
- export this from your rinkeby metamask walletETHERSCAN_KEY
- get this from the etherscan api
Next, source the environment variables into your shell:
source .env
Use forge to run the deploy script, which can take a few minutes to complete:
forge script script/IDRegistry.s.sol:IDRegistryScript --rpc-url $RINKEBY_RPC_URL --private-key $RINKEBY_PRIVATE_KEY --broadcast --verify --etherscan-api-key $ETHERSCAN_KEY -vvvv
The deploy script will generate .json outputs to track the latest deployments and transactions. Do not commit these changes unless you are modifying one of the published contracts above.
You can learn more about Foundry by reading the book.
Slither can be used to perform static analysis on the code and uncover security issues. Any significant code changes should have a slither run performed and we plan to add this into CI soon. Follow the instructions to install slither with pip and then run slither .
to view the report.
Forge ships with a gas reporting tool which provides gas reports for function calls. It can be invoked with forge test --gas-report
. But these numbers can be misleading because test suites invoke functions in ways that make them terminate very early. Some functions also vary in cost for the same code path because of storage initialization during certain invocations.
The best way to estimate gas usage accurately is to write a special test suite that follows code paths that you expect to see in real-world usage. Running the gas report on just this suite will give you the most accurate estimate.
If you see a solc dyld error like the one below and you are on an M1, follow the steps here: foundry-rs/foundry#2712
Solc Error: dyld[35225]: Library not loaded: '/opt/homebrew/opt/z3/lib/libz3.dylib'
Referenced from: '/Users/<yourusername>/.svm/0.8.16/solc-0.8.16'
Reason: tried: '/opt/homebrew/opt/z3/lib/libz3.dylib' (no such file), '/usr/local/lib/libz3.dylib' (no such file), '/usr/lib/libz3.dylib' (no such file)