Skip to content

Instantly share code, notes, and snippets.

@miguelmota
Last active September 21, 2020 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miguelmota/12717785f77e3dd4b5582dcde24e367c to your computer and use it in GitHub Desktop.
Save miguelmota/12717785f77e3dd4b5582dcde24e367c to your computer and use it in GitHub Desktop.
UNI token claim checker
const fs = require('fs')
const fetch = require('node-fetch')
const BN = require('bignumber.js')
async function makeRequest (address) {
const url = `https://gentle-frost-9e74.uniswap.workers.dev/1/${address}`
const res = await fetch(url)
const json = await res.json()
return json
}
async function main () {
const data = fs.readFileSync('addresses.csv', 'utf8')
const lines = data.split('\n')
const startIndex = process.argv[2] >>> 0
for (let i = startIndex; i < lines.length; i++) {
const address = lines[i]
if (!address) {
console.error(`${i} empty line`)
continue
}
try {
const result = await makeRequest(address)
const amountHex = result.amount
if (!amountHex) {
console.error(`${i} ${address} ${result.message}`)
continue
}
const amount = new BN(amountHex).div(new BN(10e17)).toNumber()
console.log(`${i} ${address} ${amount}`)
} catch (err) {
console.error(`${i} ${address} ${err.message}`)
}
}
}
main()
// Usage:
// $ touch addresses.csv
// $ node index.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment