# \[HACK BOUNTY\] $HYPE leaderboard

**URL:** <https://gov.near.org/t/hack-bounty-hype-leaderboard/4761>\
**Category:** Creatives DAO\
**Tags:** hype-dao\
**Created:** [August 21, 2021, 3:47pm UTC](https://gov.near.org/t/hack-bounty-hype-leaderboard/4761 "2021-08-21T15:47:18Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![erikli](https://dub1.discourse-cdn.com/flex005/user_avatar/gov.near.org/erikli/32/4727_2.png) [@erikli](https://gov.near.org/u/erikli)\
**Post date:** [August 21, 2021, 3:47pm UTC](https://gov.near.org/t/hack-bounty-hype-leaderboard/4761/1 "2021-08-21T15:47:18Z")

</div>

# HYPE leaderboard

- Bounty: [$HYPE leaderboard component](https://tree.taiga.io/project/starpause-hype-dao/us/8?kanban-include_attachments=1&kanban-include_tasks=1&kanban-status=2503432)
- PR: [Create $HYPE leaderboard by erak · Pull Request #8 · HypeDAO/HypeDAO · GitHub](https://github.com/HypeDAO/HypeDAO/pull/8)

I’ve implemented a `board` component that retrieves the $HYPE balance of a (so far) hard-coded list of accounts. It uses a wallet connection stored in a newly introduced application-wide state, which is applied by the $HYPE registration button during sign-in process.

 ![HypeDAO_pr_8_image_1](https://europe1.discourse-cdn.com/flex005/uploads/gov_near/original/2X/b/b463594f2d57ccab86786792ee58e967a3eea203.jpeg)

## Open questions

- Who do we compile the account list? Some options we discussed so far:

- How to make board accessible from UI?

Looking forward to your feedback!

---

<div class="post-metadata">

**Author:** ![mxjxn](https://dub1.discourse-cdn.com/flex005/user_avatar/gov.near.org/mxjxn/32/406_2.png) [@mxjxn](https://gov.near.org/u/mxjxn)\
**Post date:** [August 21, 2021, 4:13pm UTC](https://gov.near.org/t/hack-bounty-hype-leaderboard/4761/2 "2021-08-21T16:13:19Z")

</div>

This is awesome so far!

> [@erikli](#):
>
> Who do we compile the account list? Some options we discussed so far:

After we chatted, I found this example code to [get recent transaction details](https://docs.near.org/docs/api/naj-cookbook#recent-transaction-details).

In the spirit of decentralization, this seems like something well suited for a Graph Protocl subgraph, as I hear they’ll be working with NEAR soon!

In the meanwhile we could cache data server-side and query blocks ourselves… I dont know the best way to go about that, do you have any input @EV3RETH?

---

<div class="post-metadata">

**Author:** ![EV3RETH](https://dub1.discourse-cdn.com/flex005/user_avatar/gov.near.org/ev3reth/32/27050_2.png) [@EV3RETH](https://gov.near.org/u/EV3RETH)\
**Post date:** [August 22, 2021, 3:49am UTC](https://gov.near.org/t/hack-bounty-hype-leaderboard/4761/3 "2021-08-22T03:49:02Z")

</div>

As far as getting the data goes, we either need to cache/index transactions ourselves or wait for Graph to provide a similar service.

UI wise I was actually thinking the $HYPE button on the left would act as the portal to all things $HYPE related. Although we do need to figure out a system for sub/pages and navigation as we add more areas to the site. Looking forward to chatting with you about it all!

---

<div class="post-metadata">

**Author:** ![erikli](https://dub1.discourse-cdn.com/flex005/user_avatar/gov.near.org/erikli/32/4727_2.png) [@erikli](https://gov.near.org/u/erikli)\
**Post date:** [August 22, 2021, 10:34am UTC](https://gov.near.org/t/hack-bounty-hype-leaderboard/4761/4 "2021-08-22T10:34:49Z")

</div>

@mxjxn Thanks a lot for the hint. I managed to build a CLI tool called [near-ft-query](https://github.com/erak/near-ft-query) that can find and decode contract calls to `hype.tkn.near` for in interval of blocks:

```auto
➜ near-ft-query git:(main) ✗ ./bin/run test
Testing query...
Reading block AdLkmrttoBqYsbk386UdsDSqbFMKu3hcoAXp8DPSpu9D
Reading block 83vrZzXWPYc14a7ZzdywfW9HevNy1TWTT1hxKLu2rDZU
MATCHING TRANSACTIONS: [
  {
    actions: [[Object] ],
    hash: 'EkjKtijwBywPmtzKQNpqDnTK5Xb5utqZ4kGzRQMqQabz',
    nonce: 42193076000053,
    public_key: 'ed25519:9uAJ83bgcStumeWccZyaGm4Bwd1Cou3joLbmurDafw6x',
    receiver_id: 'hype.tkn.near',
    signature: 'ed25519:329hJn4KkChNASazBCvdzjRjMuhncsMYpd4TaoJVa4AsuD7x9KGAVjF4qap9rYNYo4GbFtSH2w2xJdEtooSrv7Wm',
    signer_id: 'mxjxn.near'
  }
]
TRANSACTION LINKS: [
  {
    method: 'ft_transfer',
    arguments: { amount: '25000000000000000000', receiver_id: 'lilses.near' },
    link: 'https://explorer.near.org/transactions/EkjKtijwBywPmtzKQNpqDnTK5Xb5utqZ4kGzRQMqQabz'
  }
]

```

@EV3RETH I think it would be cool to develop that further and cache all $HYPE balances in a JSON file, that an update would only append to. We could then try to run this update once a day from somewhere (Github CI, if it allows such a long-running “blockchain task”) and store it on IPFS or Arweave?

---

<div class="post-metadata">

**Author:** ![erikli](https://dub1.discourse-cdn.com/flex005/user_avatar/gov.near.org/erikli/32/4727_2.png) [@erikli](https://gov.near.org/u/erikli)\
**Post date:** [August 22, 2021, 4:02pm UTC](https://gov.near.org/t/hack-bounty-hype-leaderboard/4761/5 "2021-08-22T16:02:01Z")

</div>

I’ve continued working on this a bit and might have come up with an intermediate solution prior to GraphQL support.

The CLI block query tool [near-ft-query](https://github.com/erak/near-ft-query) can now be used to

- a) Initialize a cache file that contains timestamps, the oldest block and all active accounts. These can be passed via the commandline: `near-ft-query init erikli.near,mxjxn.near`
- b) Update an existing cache by querying all active accounts between the oldest block and the current one (currently hard-coded)

This gives us the opportunity to create a cache file with a (so far hand-compiled) list of active accounts from the time of HYPE creation until today. This file could be stored on Github where the leaderboard component reads it from. We could move on with that.

The next step could be to test the update mechanism and decide on an environment to run the CLI in. From here the cache file could be updated daily by taking only the blocks since last update into account.

---

<div class="post-metadata">

**Author:** ![erikli](https://dub1.discourse-cdn.com/flex005/user_avatar/gov.near.org/erikli/32/4727_2.png) [@erikli](https://gov.near.org/u/erikli)\
**Post date:** [August 22, 2021, 4:04pm UTC](https://gov.near.org/t/hack-bounty-hype-leaderboard/4761/6 "2021-08-22T16:04:08Z")

</div>

And here’s a list of all active accounts (excluding councils) that have their `receiver_id` set in `ft_transfer` from [block #43446577](https://explorer.near.org/blocks/BuDrmBTYbzqCDq59B4kdme4YzdYMVfJskCNnookFaq6A) to [block 45884317](https://explorer.near.org/blocks/FHgWE6VcvRjLwZsgmSQAJiqbUrBAz8eixwxsqMQaqof5):

- chloe.near
- defeatofclay.near
- empress.near
- holikao.near
- joshua.near
- jsnow.near
- lilses.near
- magusz.near
- marafonec2021.near
- q-hmd.near
- starpause.near
- tabear.near
- trendheo.near
- verbash.near

Ps: based on a manual [explorer](https://explorer.near.org/accounts/hype.tkn.near) query 😉

Also, I’ve made it available in the right JSON format [here](https://raw.githubusercontent.com/erak/near-ft-query/main/hype-tkn-near-active-accounts.json)

---

<div class="post-metadata">

**Author:** ![EV3RETH](https://dub1.discourse-cdn.com/flex005/user_avatar/gov.near.org/ev3reth/32/27050_2.png) [@EV3RETH](https://gov.near.org/u/EV3RETH)\
**Post date:** [August 22, 2021, 10:09pm UTC](https://gov.near.org/t/hack-bounty-hype-leaderboard/4761/7 "2021-08-22T22:09:15Z")

</div>

Thank you for all the work thus far. I will say anything that needs to be updated manually is kinda outa the question.

We are going to be building a DB of active users and artists shortly, I think the best short term yet scalable solution is to wait on that and have "$HYPE amount just be a field/column in the profile table.  
Every-time a user logs in we would update their total HYPE amount, and we could also make a master function that iterates through active accounts and manually updates their info in the DB

---

<div class="post-metadata">

**Author:** ![EV3RETH](https://dub1.discourse-cdn.com/flex005/user_avatar/gov.near.org/ev3reth/32/27050_2.png) [@EV3RETH](https://gov.near.org/u/EV3RETH)\
**Post date:** [August 22, 2021, 10:15pm UTC](https://gov.near.org/t/hack-bounty-hype-leaderboard/4761/8 "2021-08-22T22:15:40Z")

</div>

If your CLI command can check the entire history in an efficient way, then we could just have it be a button that people click to build the leader board in real time. That would be sufficient for now till the db is up

---

<div class="post-metadata">

**Author:** ![erikli](https://dub1.discourse-cdn.com/flex005/user_avatar/gov.near.org/erikli/32/4727_2.png) [@erikli](https://gov.near.org/u/erikli)\
**Post date:** [August 23, 2021, 3:44pm UTC](https://gov.near.org/t/hack-bounty-hype-leaderboard/4761/9 "2021-08-23T15:44:47Z")

</div>

Spent some time thinking about that earlier today. The most important part is getting all accounts that received $HYPE through the contract, right? As long as I’m not missing something here, we’d either need an indexer that updates that list every time ‘ft\_transfer’ was called or scrape recent blocks and do the update ourselves (pseudo-indexer). Both need some thinking where that account list is stored and where the (pseudo)-indexer should run. The pseudo-indexer needs more thinking on how and when to efficiently retrieve new blocks.

So if we have that list somewhere stored and updated, the actual amount an account has can be retrieved from the contract via direct call in realtime.

@EV3RETH Could you give some more information on how you’d imagine the mechanism to work considering your idea on the login update?

---

<div class="post-metadata">

**Author:** ![EV3RETH](https://dub1.discourse-cdn.com/flex005/user_avatar/gov.near.org/ev3reth/32/27050_2.png) [@EV3RETH](https://gov.near.org/u/EV3RETH)\
**Post date:** [August 24, 2021, 12:33am UTC](https://gov.near.org/t/hack-bounty-hype-leaderboard/4761/10 "2021-08-24T00:33:29Z")

</div>

My thinking is we just have a API call that updates a users stored HYPE amount on our soon to be db every time a user connects their wallet/makes any meaningful tx through our site. We wouldn’t really be interacting with blocks at all. Just logging info when we observe it via user activity.  
Obviously this is a very limited way of doing things. But I don’t think we have the capabilities to run our own true indexer.

---

<div class="post-metadata">

**Author:** ![EV3RETH](https://dub1.discourse-cdn.com/flex005/user_avatar/gov.near.org/ev3reth/32/27050_2.png) [@EV3RETH](https://gov.near.org/u/EV3RETH)\
**Post date:** [August 24, 2021, 12:38am UTC](https://gov.near.org/t/hack-bounty-hype-leaderboard/4761/11 "2021-08-24T00:38:33Z")

</div>

Contacting you via Telegram to see how we can call this bounty complete as the ideal situation means waiting a bit.

---

<div class="post-metadata">

**Author:** ![erikli](https://dub1.discourse-cdn.com/flex005/user_avatar/gov.near.org/erikli/32/4727_2.png) [@erikli](https://gov.near.org/u/erikli)\
**Post date:** [August 24, 2021, 3:49pm UTC](https://gov.near.org/t/hack-bounty-hype-leaderboard/4761/12 "2021-08-24T15:49:06Z")

</div>

Omg, I couldn’t stop working on it. But I came up with a system that could for us until the internal database is ready (because I also liked the idea of updating it on login, @EV3RETH).

I moved the CLI tool into the HypeDAO repository and created a Github Action. That action runs the CLI update command in order to automatically update a manually initialized JSON cache file every hour. This cache file lives on a separate branch in the monorepo.

List of components:

- [PR for the CLI tool](https://github.com/HypeDAO/HypeDAO/pull/11)
- [JSON cache file on its own branch](https://github.com/erak/HypeDAO/blob/cache/dao-stats-hype.tkn.near.json)
- [Github Actions](https://github.com/erak/HypeDAO/actions)

So, my plan to get the leaderboard going would be:

1. Finish leaderboard UI component and move that out of WIP and thus finish the bounty

- use newly introduced JSON cache file from Github and retrieve account balances based on that file
- Make leaderboard available from HYPE registration button (through drop-down)

1. Stabilize and finish up account cache mechanism (more testing)

What does everyone think about this?

---

<div class="post-metadata">

**Author:** ![EV3RETH](https://dub1.discourse-cdn.com/flex005/user_avatar/gov.near.org/ev3reth/32/27050_2.png) [@EV3RETH](https://gov.near.org/u/EV3RETH)\
**Post date:** [August 24, 2021, 3:51pm UTC](https://gov.near.org/t/hack-bounty-hype-leaderboard/4761/13 "2021-08-24T15:51:09Z")

</div>

That sounds awesome! Great plan

---

<div class="post-metadata">

**Author:** ![isonar](https://dub1.discourse-cdn.com/flex005/user_avatar/gov.near.org/isonar/32/4755_2.png) [@isonar](https://gov.near.org/u/isonar)\
**Post date:** [August 27, 2021, 1:47pm UTC](https://gov.near.org/t/hack-bounty-hype-leaderboard/4761/14 "2021-08-27T13:47:36Z")

</div>

Hi All! How do I apply for a MetaBuidl “NFTs & DAOs” Challenge?

---

<div class="post-metadata">

**Author:** ![mxjxn](https://dub1.discourse-cdn.com/flex005/user_avatar/gov.near.org/mxjxn/32/406_2.png) [@mxjxn](https://gov.near.org/u/mxjxn)\
**Post date:** [August 27, 2021, 3:59pm UTC](https://gov.near.org/t/hack-bounty-hype-leaderboard/4761/15 "2021-08-27T15:59:54Z")

</div>

I will create a new thread about the hackathon right now, please submit your idea that you’d like to start working on there!! Thanks for asking!!

---

<div class="post-metadata">

**Author:** ![mxjxn](https://dub1.discourse-cdn.com/flex005/user_avatar/gov.near.org/mxjxn/32/406_2.png) [@mxjxn](https://gov.near.org/u/mxjxn)\
**Post date:** [August 27, 2021, 4:21pm UTC](https://gov.near.org/t/hack-bounty-hype-leaderboard/4761/16 "2021-08-27T16:21:55Z")

</div>

Forgot to tag you in my reply but check out the new post I made! Just give it a read and submit a reply to get started!

---

<div class="post-metadata">

**Author:** ![erikli](https://dub1.discourse-cdn.com/flex005/user_avatar/gov.near.org/erikli/32/4727_2.png) [@erikli](https://gov.near.org/u/erikli)\
**Post date:** [August 27, 2021, 5:07pm UTC](https://gov.near.org/t/hack-bounty-hype-leaderboard/4761/17 "2021-08-27T17:07:10Z")

</div>

Hey all, I’ve updated the cache mechanism. It should update $HYPE receivers in this [JSON file](https://github.com/erak/HypeDAO/blob/cache/dao-stats-hype.tkn.near.json) every 30 min.

Would be cool to get some more testing (as I might just spotted unintended behaviour in transaction match function).

Please also check the PRs and action runs on Github, linked [here](http://gov.near.org/t/dev-hype-leaderboard/4761/12).

Thanks 🙂

---

<div class="post-metadata">

**Author:** ![mxjxn](https://dub1.discourse-cdn.com/flex005/user_avatar/gov.near.org/mxjxn/32/406_2.png) [@mxjxn](https://gov.near.org/u/mxjxn)\
**Post date:** [August 27, 2021, 5:10pm UTC](https://gov.near.org/t/hack-bounty-hype-leaderboard/4761/18 "2021-08-27T17:10:24Z")

</div>

This is amazing, you’re an absolute legend! Looking forward to taking a closer look as soon as I can! Got a big bounty coming your way for sure for all the great work you’ve done!

---

<div class="post-metadata">

**Author:** ![EV3RETH](https://dub1.discourse-cdn.com/flex005/user_avatar/gov.near.org/ev3reth/32/27050_2.png) [@EV3RETH](https://gov.near.org/u/EV3RETH)\
**Post date:** [August 31, 2021, 3:26am UTC](https://gov.near.org/t/hack-bounty-hype-leaderboard/4761/19 "2021-08-31T03:26:12Z")

</div>

PRs have been checked, just a couple requests and then we are all good!

---

<div class="post-metadata">

**Author:** ![erikli](https://dub1.discourse-cdn.com/flex005/user_avatar/gov.near.org/erikli/32/4727_2.png) [@erikli](https://gov.near.org/u/erikli)\
**Post date:** [September 4, 2021, 10:13am UTC](https://gov.near.org/t/hack-bounty-hype-leaderboard/4761/20 "2021-09-04T10:13:28Z")

</div>

So, I hope this is the final update 🙂 I’ve pushed more changes to both PRs:

### Cache

- PR: [Cache active $HYPE accounts w/ 'dao-stats' CLI and a Github action by erak · Pull Request #11 · HypeDAO/HypeDAO · GitHub](https://github.com/HypeDAO/HypeDAO/pull/11)
- Added a lot more documentation, cache update is running on personal branch until merge ([Workflow runs · erak/HypeDAO · GitHub](https://github.com/erak/HypeDAO/actions))
- Needs further monitoring (and more adjustments eventually)

### Leaderboard

- PR: [Create $HYPE leaderboard by erak · Pull Request #8 · HypeDAO/HypeDAO · GitHub](https://github.com/HypeDAO/HypeDAO/pull/8)
- Put some more work into the $HYPE registration button, that is now a menu and links to the board

There’s a preview deployed here: [https://hype-dao-bxznyltsf-hypedao.vercel.app/](https://hype-dao-bxznyltsf-hypedao.vercel.app/)

Please let me know, if there’s anything that needs to be changed 🙂
