Created
October 31, 2022 12:02
-
-
Save thurendous/2f55502372c5ec9dbb3ba3656a280346 to your computer and use it in GitHub Desktop.
Get Mumbai Matic Token
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment