Skip to content

Instantly share code, notes, and snippets.

@allenday
Last active March 1, 2023 22:42
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 allenday/fafa287e373efcda60a6e85da848f91f to your computer and use it in GitHub Desktop.
Save allenday/fafa287e373efcda60a6e85da848f91f to your computer and use it in GitHub Desktop.
Chainlink + Google Analytics - code snippet to write votes to smart contract
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