Follow the full written tutorial here: https://docs.alchemy.com/alchemy/tutorials/how-to-code-and-deploy-a-polygon-smart-contract Follow the full video tutorial here: (TBD)
npm install- Rename
.env-exampleto.env, and populate the variable values.- Grab
API_URLfrom www.alchemy.com by setting up a Polygon Mumbai testnet app. - For
PRIVATE_KEY, use your Ethereum wallet address's corresponding private key. - You can leave
CONTRACT_ADDRESSblank until you deploy withnpx run scripts/sample-script.js, then grab the address where you deployed your contract to. ALCHEMY_API_KEYis very similar toAPI_URLexcept you can remove the http or ws prefix.MATIC_URLyou can grab from www.alchemy.com but make sure your Alchemy app is a Polygon Mainnet app.
- Grab
- run
npx run scripts/sample-script.js --network mumbaito deploy your contract to Mumbai testnet - run
npx run scripts/greet.js --network mumbaito modify blockchain state by calling the Greet function on your smart contract. - Repeat those steps with
--network maticto deploy and interact on Polygon (MATIC) mainnet chain.