/application
directory contains a /const
directory, which has two files:
chains.ts
: Define the testnet and mainnet chains your smart contracts are deployed to.contracts.ts
: Define the addresses of your smart contracts on each chain.DEVELOPMENT_CHAIN
and PRODUCTION_CHAIN
variables to your chosen chains, and you’re good to go.
By default, the application uses the Polygon Mumbai
test network for testing and the Polygon Mainnet
network for production:
IS_DEV_ENV
detects whether you’re running the application in a development environment or not.
The CHAIN
variable uses that value to return your chosen development chain in development and your chosen production chain in production.
contracts.ts
file is where you put the addresses of your smart contracts.
For each smart contract you want to connect to, you can follow the same pattern below:
yarn generate
from the application directory. This will create a thirdweb.json
file at the root of your app;
which you can modify and re-run yarn generate
to pull in new ABIs, or update existing ones.
yarn generate
with the below configuration inside thirdweb.json
will pull in the ABI for the
0x2E7
smart contract on the Polygon Mumbai
test network:
generate
, smart contract interactions become type-safe as the ABIs are now available to the IDE.
It also provides a performance increase as the function
doesn’t need to fetch the ABI at run-time.
/node_modules/@thirdweb-dev/generated-abis/dist
directory.