Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to watch for staking rewards event? #829

Open
jasoncsli opened this issue Mar 16, 2023 · 0 comments
Open

How to watch for staking rewards event? #829

jasoncsli opened this issue Mar 16, 2023 · 0 comments
Labels
question Further information is requested

Comments

@jasoncsli
Copy link

jasoncsli commented Mar 16, 2023

Ask a question

I would like to index all rewards into my database. From my previous experience in Solana, staking rewards have been sent in the block. So I just listen to block-creation and loop through all rewards in this block, and then save them in my database. How could I do by cardano-graphql? I can't find the staking rewards of a block by block query. I do find rewards fields in slot leader field and epoch field of block query, but I think they have rewards are not in current epochs (or not in current block).

  1. How could I get reward event in real time ? Once the staking reward has been sent to address in the new block, I need to save it in my db too.

query {
    rewards(where: { receivedIn: { number: {_eq: 142}} } ) {
        address
        amount
        type
        earnedIn {
            number
        }
        receivedIn {
            number
        }
    }
}

This is a way to find all rewards in the epoch. For example, if current epoch is 142, when is the accounts receives the staking rewards in epoch 142? In Solana, it is first block(slot) in the epoch.

@jasoncsli jasoncsli added the question Further information is requested label Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant