Getting more MATIC on Polygon Mumbai

Blockchain Presence
Blockchain Presence
5 min readMay 23, 2022

This article aims to provide solutions to anyone needing MATIC to run tests on Polygon’s testnet. If you are tired of faulty faucet websites and want to acquire enough MATIC to complete tasks promptly, this blog is for you. After this read you should be able to automatically test MATIC from the Polygon tap, generate multiple addresses to which to send the coins you need, and transfer them to a single account.

What is a testnet?

A testnet is a test version of a blockchain powered by the same, or newer, version of the underlying software. Its purpose is to test and conduct experiments without risking real funds on the main chain. The currency used on a testnet is independent and distinct from the one officially used on the Mainnet. Thus, these coins have no value and can be obtained for free from the faucets. Testnets can be reset at any time.

Testnets are a way to test applications on new versions of the blockchain software, develop applications without risking the loss of real funds, or analyze blockchain data at a smaller scale compared to doing it on the public network. They can even provide early access to a blockchain before its official release.

Polygon Testnet: Mumbai

As a secondary scaling solution, the Polygon network aims to address the limitations of the Ethereum platform, namely high transaction fees and slow transaction processing. Polygon enables the deployment of existing blockchain networks and custom blockchains. Moreover, it allows for communication between existing blockchain networks and Ethereum, and can be used as a tool to make them compatible. MATIC is the currency required to cover the fees for transactions that occur on the platform (Polygon’s gas fees).

The best thing to get started with the latter is to make some simulations on Mumbai (Polygon’s test network). Just like on the Polygon mainnet, the token used on Mumbai is MATIC. When trying to discover the Polygon chain, it is necessary to get a few MATIC into your wallet to start making transactions.

Polygon Faucet

A Faucet is a tool that provides a limited amount of funds to start using a cryptocurrency without having to buy any. To reach the Polygon Faucet, simply click on the following link: https://faucet.polygon.technology/.

How to get the MATIC?

The first method is getting MATIC directly from the Mumbai faucet to your account. For that to happen, you first have to enter the address to your account, to which the free MATIC will be transferred from the faucet.

The principle is the same as on Polygon’s mainnet: opy your address and paste it onto the website before clicking on the « submit » button. With this method, you can only get 0.2 MATIC at the time. If you need more, you have to repeat these steps until obtaining a suitable amount. Not only is it quite time-consuming, but there is also a limit on the number of tokens as well as the frequency of withdrawals. That is why we created a script that runs by itself and automates the process described above.

The code must be entered in the console of Visual Studio, which is a tool to write programming code. For more information on how to download it, simply go to: https://docs.microsoft.com/en-us/visualstudio/get-started/visual-basic/tutorial-console?view=vs-2022

If you need LESS than 10 MATIC

You can use the light version “matic_gatherer.js ” by typing the following code in the command line:

node matic-gatherer ‘your account address’

- After adding the 10 MATIC to your account, it will show the following error:

error: "Matic Tokens are ideally used to pay for gas, the address you're requesting from has enough to pay for gas. If you require in bulk please contact us on Discord.

After your account balance is more than 10 MATIC, the website will show this result error. This happens because the faucet considers that your account has enough MATIC to run some tests and will not allow you to get more Mumbai MATIC. So, you can get at most 10 MATIC on a given account from the faucet directly.

Nevertheless, you can transfer all 10 MATIC to other addresses to avoid this limit. We explain how to do this in an automated manner in the following chapter.

If you need MORE than 10 MATIC

This method is more advanced than the previous one. As explained before, the faucet will check your balance, and if you already have 10 MATIC, it will not send you any more coins. In return, this forces you to transfer those coins manually every time you reach the 10 MATIC threshold. This lack of efficiency can be irritating as we do not want to constantly check our account’s balance and carry out endless transfers to other accounts.

So, we created a method to solve the transfer issue that allows you to automatically generate multiple accounts and collect abundant MATIC from the faucet. Whenever one of these accounts reaches the 10 MATIC limit, the code itself will check the balance and transfer all MATIC from this account to your main account. Then a new address is generated and as this process repeats itself, the MATIC will accumulate in your main wallet.

It is like asking many friends to collect MATIC using their accounts, and as they respectively reach the 10 MATIC limit, transferring those MATIC to your account. You will then very easily get much more than 10 MATIC without multiplying your efforts.

You can use the standard version “matic_gatherer-v2.js ” by typing the following command:

node matic-gatherer-v2 `your account address`import fetch from ‘node-fetch’;const getAddress = () => {const address = process.argv[2];if (!address) {console.log(`Please add the address as script argument`);process.exit(1);}return address;};const getMatic = async (address) => {console.log(`fetching matic to ‘${address}’`);fetch(`https://api.faucet.matic.network/transferTokens`, {method: post,body: JSON.stringify({network: mumbai,address: address,token: maticToken,}),headers: { ‘Content-Type’: application/json },}).then(res => res.json()).then(console.log)const delay = ms => new Promise(resolve => setTimeout(resolve, ms))// const delay = async (ms) => setTimeout(resolve, ms);console.log(`waiting 2 minutes`);await delay(2 * 60000);};const address = getAddress();

- In Windows

node ./matic-gatherer-v2.js  `your account address `

This code will keep on generating a new address every 10 MATIC come out of the faucet and it will transfer them to your main account. Check your balance on MetaMask to see if you have all the MATIC required. If so, you can simply close the terminal to stop the process.

Voilà! In just a couple of minutes and without much effort you now have more MATIC to use on the Polygon testnet than you could even dream of.

Note that you can find all of the commands that appear here in getmatic.md.

By Elise J.M. & Xiaoran Wei

--

--

Blockchain Presence
Blockchain Presence

Blockchain Presence is an innovative blockchain oracle solution developed by a project team at the University of Zurich between 2019–2020