Last active
March 1, 2023 22:42
-
-
Save allenday/fafa287e373efcda60a6e85da848f91f to your computer and use it in GitHub Desktop.
Chainlink + Google Analytics - code snippet to write votes to smart contract
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
let item1Votes | |
try { | |
item1Votes = parseInt(responses[0].data.rows[0].metricValues[0].value) | |
} catch { | |
item1Votes = 0 | |
} | |
let item2Votes | |
try { | |
item2Votes = parseInt(responses[1].data.rows[0].metricValues[0].value) | |
} catch { | |
item2Votes = 0 | |
} | |
console.log(`Item 1 votes: ${item1Votes}\nItem 2 votes: ${item2Votes}`) | |
return Buffer.concat([ Functions.encodeUint256(item1Votes), Functions.encodeUint256(item2Votes) ]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment