Skip to content

GetBlock

Content disclaimer

Please view the third-party content disclaimer here.

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:

  1. Get started on GetBlock and access test nodes.
  2. Create a wallet address with Metamask.
  3. Add test tokens to your wallet.
  4. Compile and deploy a smart contract using Remix
  5. Check the status of your smart contract.

Preparation

  1. The first step is to sign up with Getblock via wallet or email via

img

  1. Create an endpoint for Polygon testnet (Mumbai).

img

  1. 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

img

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

  1. Visit the official Remix website. Remix is a Web-based IDE for Ethereum smart contract development in Solidity.

  2. Click on the “Create a new file” button located on the left side of the page.

  3. Select “Storage.sol” from Remix as an example of a contract.

img

  1. Deploy the smart contract by clicking on the “Deploy & Run Transactions” tab.

  2. Click on the “Deploy & Run Transactions” tab in Remix, located on the left-hand side of the screen.

  3. 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.

img

  1. Locate the storage variable you want to test.

  2. Choose “Injected provider” as the provider and select “Metamask” as the wallet.

img

Check that your smart contract has been created on the network by looking at the Remix output panel.

  1. 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.

  2. Click on the search button or hit enter.

img

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:

  1. 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.”

img

  1. 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.

  2. Click on the “Transact” button to confirm the transaction in Metamask.

img

  1. 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”.

  2. Find the “storage” variable and click on the “Read” button. The new value of the variable should now be displayed as “14”.

img

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.


Last update: February 5, 2024
Authors: kmurphypolygon (3.0%), Nadim Kobeissi (97.0%)