Deploy a Smart Contract on Polygon using GetBlock
The Polygon API endpoint by GetBlock is a useful tool for early-stage teams that want to take advantage of Polygon's benefits. In this tutorial, we will walk you through the steps to create and deploy an ERC-20 smart contract on the Polygon Mumbai testnet using Metamask, Remix, and GetBlock.
You will learn how to use GetBlock to create and deploy a smart contract on the Mumbai Testnet using GetBlock endpoints.
What you will do
In this tutorial, you will:
- Get started on GetBlock and access test nodes.
- Create a wallet address with Metamask.
- Add test tokens to your wallet.
- Compile and deploy a smart contract using Remix
- Check the status of your smart contract.
The first step is to sign up with Getblock via wallet or email via
Create an endpoint for Polygon testnet (Mumbai).
Then enter Metamask and choose to connect a network manually, connect your Metamask to the Mumbai Testnet adding your GetBlock endpoint in the RPC URL line
If you don't have any tokens in your account, you can request some from the Mumbai faucet through the faucet website.
Smart Contract Development
Visit the official Remix website. Remix is a Web-based IDE for Ethereum smart contract development in Solidity.
Click on the "Create a new file" button located on the left side of the page.
Select “Storage.sol” from Remix as an example of a contract.
Deploy the smart contract by clicking on the “Deploy & Run Transactions” tab.
Click on the “Deploy & Run Transactions” tab in Remix, located on the left-hand side of the screen.
In the “Contract” dropdown menu, select the name of the smart contract you want to deploy and click on the “Deploy” button to deploy the smart contract. A Metamask window will pop up asking you to confirm the transaction. Click on the “Confirm” button to proceed.Wait for the transaction to be confirmed on the Polygon network.
You can track the status of the transaction in the Metamask window or by checking the transaction hash on the Polygon explorer.
Once the transaction has been confirmed, you should see a green checkmark and a message indicating that the contract has been deployed successfully.
Locate the storage variable you want to test.
Choose "Injected provider" as the provider and select "Metamask" as the wallet.
Check that your smart contract has been created on the network by looking at the Remix output panel.
Click on the "Polygon (Matic) Mainnet" dropdown menu located at the top right corner of the page and select "Mumbai Testnet" from the list of available networks. Then enter the address of your smart contract in the search bar located at the top of the page.
Click on the search button or hit enter.
Smart contract URL: https://mumbai.polygonscan.com/address/0xa4d552dce0e26564ec1737638705584ce9ed351b
If your smart contract has been successfully deployed, you should see the contract details including its address, balance, and transaction history. Congratulations, you have successfully deployed a smart contract on the Mumbai Testnet!
Testing and Verification
Once you have deployed your smart contract on the Polygon test network using GetBlock, it is important to test and verify its functionality to ensure that it works as intended. Here are some steps you can take for testing and verification:
Open the smart contract in Remix and locate the storage variable you want to test. In this example, we will use a variable called "storage" that initially has a value of 12."
Change the value of the variable to 14 by entering "14" in the "Store" field and saving the value on the network after confirming the operation in Metamask.
Click on the "Transact" button to confirm the transaction in Metamask.
Wait for the transaction to be added to a network block. Once the transaction is confirmed, navigate to the "Read Contract" section under "Deployed Contracts".
Find the "storage" variable and click on the "Read" button. The new value of the variable should now be displayed as "14".
By following these steps, you can ensure that your smart contract works as intended and is secure and reliable for your users.
Congratulations, you have successfully deployed a smart contract on the Mumbai Testnet!
If you have any additional questions or would like to share your experience, feel free to join our community of Web3 developers who are always ready to chat.