Yes, you can use the randomness from the relay chain. It is currently not that easy, but you should be able to do it in the following way:
In your runtime:
impl cumulus_parachain_system::Config for Runtime {
type OnSystemEvent = MySystemEventHandler;
...
}
Wherever MySystemEventHandler
is implemented:
impl OnSystemEvent for MySystemEventHandler {
fn on_validation_data(data: &PersistedValidationData) {
let proof = cumulus_parachain_system::RelayChainStateProof::new(my_para_id, data.relay_parent_storage_root, cumulus_parachain_system::Pallet::relay_state_proof()).expect("Invalid relay chain proof");
use cumulus_primitives_core::relay_chain::well_known_keys as relay_well_known_keys;
let randomness = proof.read_entry::<schnorrkel::Randomness>(relay_well_known_keys::CURRENT_BLOCK_RANDOMNESS);
}
..
}
There exists three different types of randomness that BABE can provide to you. See here for a description of each of them.