6

I've used await api.query.staking.nominators(address) but that just returns something like:

{
    "result": {
        "targets": [
            "{nominatorId1}",
            "{nominatorId2}"
        ],
        "submittedIn": 4957,
        "suppressed": false
    }
}

This is useful but I don't know the statuses of each of them. Thank you!

4
  • What does "status" mean? What kinds of status do you want?
    – Shawn Tabrizi
    Commented Apr 4, 2022 at 20:50
  • My colleague posted this because my IP address is blocked for some reason... Status meaning if the nomination is "active", "inactive", or "waiting". support.polkadot.network/support/solutions/articles/… Commented Apr 4, 2022 at 21:40
  • Micheal, does that article not provide the answers here? I would be happy to upvote the answer and proposed edits to the question to refine it :)
    – Nuke
    Commented Apr 5, 2022 at 2:13
  • Thanks Dan! I'm wondering how to access that information programmatically from the API, not just through the browser portal. I think Xiu may have answered me though! Commented Apr 5, 2022 at 17:18

1 Answer 1

3

Nominators active in a specific era -

const VALIDATOR = "1..."
const NOMINATORS = ["1...", "1..."]

const opt_era_info = await api.query.staking.activeEra()
const val_exposure = await api.query.staking.erasStakers(
  opt_era_info.unwrap().index,
  VALIDATOR
)

console.log(
  val_exposure.others
    .filter(o =>
      NOMINATORS.some(n =>
        o.who.eq(n)
      )
    )
    .map(n =>
      `${n.who.toString()} => ${n.value.toString()}`
    )
    .join("\n")

)

Those inactive are the reverse, not in a specific era.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.