Based on the Polkadot.js API source code you may access the list of keys from the current authority set using the following code:
import { ApiPromise, WsProvider } from '@polkadot/api';
async function main () {
const wsProvider = new WsProvider('wss://rpc.polkadot.io');
const api = await ApiPromise.create({ provider: wsProvider });
let authorities = await api.call.authorityDiscoveryApi.authorities();
console.log('authorities: ', authorities.toJSON());
}
main().catch(console.error).finally(() => process.exit());
Or just go to https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frpc.polkadot.io#/js, paste the following, and click the play icon to view the output on the right.
console.log((await api.call.authorityDiscoveryApi.authorities()).toJSON());
The previously available function api.query.authorityDiscovery
appears to have now been removed and replaced with that Runtime call. The documentation is open-source and the Storage section doesn't appear to have been updated yet, but it does include api.call.authorityDiscoveryApi
in the Runtime section here.
For example, if you go to https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frpc.polkadot.io#/runtime, and choose endpoint authorityDiscoveryApi
and authorities()
, then click button 'Submit Runtime call', it will output the list of keys from the current authority set.