fetch_root_key function

Future<void> fetch_root_key()

For use in a local environment. This function fetches and sets the ic_root_key from the local replica.

The ic_base_url host must be set to either 127.0.0.1 or localhost, otherwise this function throws an error.

Implementation

Future<void> fetch_root_key() async {
    if (['localhost', '127.0.0.1'].contains(ic_base_url.host)) {
        Map m = await ic_status();
        ic_root_key = Uint8List.fromList(m['root_key']);
    } else {
        throw Exception('fetch_root_key can be called when the ic_base_url.host is set to 127.0.0.1 or localhost.');
    }
}