Generate
Detects all contract addresses in your project, then fetches and stores each smart contract’s ABI in memory (inside node_modules
);
improving the performance of the SDK when using functions such as getContract
and
useContract
.
Once the ABIs are cached locally, the SDK becomes strongly typed when interacting with your smart contracts.
Providing you with Intellisense and type-checking when using functions such as
contract.call
, in the TypeScript SDK,
or useContractRead
, and useContractWrite
in the React SDK.
Configuration
After the first generation, a thirdweb.json
file is created at the root of your project containing configuration for the command:
To add additional contracts to the generation process, add a new object into the contracts
array in the thirdweb.json
file:
postinstall Script
A postinstall
script is also created that performs the generate
command
after your dependencies are installed; enabling the same ABI caching process and performance improvements in your deployment environments.
You can view and customize the script inside of your package.json
.
Usage
The command recursively checks all files in your project for valid smart contract addresses and fetches the ABIs for each contract.
The ABIs are then stored locally in the projects node_modules/@thirdweb-dev/generated-abis
directory.
Functions that require the fetching of a smart contract such as getContract
and useContract
will now use the cached ABIs instead of
fetching them each time the function is called. This improves the performance of your application and allows the SDK to become strongly
typed when interacting with your smart contracts.
Options
--path <string>
or-p <string>
: Path to project--key <string>
or-k <string>
: Optional parameter to use passed in secret key, most useful for continuous integration use cases