Skip to content

Instantly share code, notes, and snippets.

@thurendous
Created October 31, 2022 12:02
Show Gist options
  • Save thurendous/2f55502372c5ec9dbb3ba3656a280346 to your computer and use it in GitHub Desktop.
Save thurendous/2f55502372c5ec9dbb3ba3656a280346 to your computer and use it in GitHub Desktop.
Get Mumbai Matic Token
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