Created
April 8, 2021 11:29
-
-
Save bustardcelly/73fc34a74446f460d03b6158e7cf1e33 to your computer and use it in GitHub Desktop.
Access token ID of OBJKT
This file contains 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
async function getTokenId (account, date) { | |
try { | |
let response = await fetch(`https://staging.api.tzkt.io/v1/accounts/${account}/operations?type=transaction`, { method: 'GET' }) | |
let json = await response.json() | |
const filter = json.filter(t => { | |
if (t.type === 'transaction') { | |
if (t.timestamp.match(date)) { | |
if (t.parameter && t.parameter.entrypoint === 'mint') { | |
return t | |
} | |
} | |
} | |
return null | |
}) | |
const map = filter.map(t => { | |
return t.parameter.value.token_id | |
}) | |
return map.length > 0 ? map[0] : undefined | |
} catch (e) { | |
console.error(e) | |
} | |
} | |
getTokenId('tz1hhaDW6YghBcdCVWkUBu76HKWzD9d1tf2i', /2021-04-04/) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment