A full-stack snippet & example to demonstrate how to implement calldata gas optimization with Solid Grinder
If you wonder how calldata optimization works, you can check it out at this guide
Note💡
The code is not audited yet. Please use it carefully in production.
Assuming that you have zellij installed:
pnpm i
cd contracts
pnpm i
cd web
pnpm i
There are two main components, which are blockchain component and web component
- Spinning up the blockchain component:
cd contracts
pnpm start
If it appears that you need to intall more dependencies, just delete /contracts/lib
, modify the command and re-run it.
Note💡
In the first time, it is needed to install relevant dependencies:
cd contracts
pnpm prepare
This will open a customized terminal with three sub-terminals, including anvil, testing and interaction.
- In another terminal, run deployment scripts to the local network:
pnpm contracts:deploy
This will atomically deploy sets of deployment scripts.
- Export deployment artifacts with formated schema to be used later in front-end part:
pnpm contracts:export-local
This schema includes address and abi.
- Running the front-end component:
pnpm web:dev
Note💡
- (Optional) kill blockchain component when not needed
cd contracts
pnpm stop
These are some guidlines to do when the front-end component can not sync to the blockchain component:
-
Delete generated files after deployment in your
contracts/broadcast/
to clear the cache, and then re-deploy again. -
Go to your Metamask extention and clear the data. There sometimes are updates in local nonce, so the checksum in front-end pass doesnot match the right ones.
Settings -> Advanced -> Clear activity and nonce data
- Rebuild again
pnpm dev
- Make sure your metamask connect to the same address which has been registered. Otherwise, register it!!
💡 Note:
You can directly send Tx to the chain via your CLI:
cast send <Contract Address> "register(address)" <Sender Address> <Addr as Argument> --private-key <Sender Privatekey>
- Open new Chrome tab every time after you have spinned up blockchain compoment and deployed the contract in order to make sure the front-end does not cache the wrong config.
See our contributing guidelines
.
💡 Note:
We acknowledge, use, and get inspiration from this amazing template: jolly-roger.