Trying to call a function marked as #[require_transactional] from on_idle() hook triggers the error Err : Transactional(NoLayer).

I realise the transactional macro is optional for extrinsics and the default behaviour of all extrinsics is transactional after this. But I'm curious if its safe to execute transactional calls from pallet hooks?

1 Answer 1


No, pallet hooks are not transactional by default, only extrinsics are.

You should be able to create a transactional layer within the pallet hook so that the error of NoLayer goes away, but generally, you should keep logic within your hooks to be infalliable.

If you choose to use a transactional layer, something as simple as this should work:

fn on_idle(_block: T::BlockNumber, remaining_weight: Weight) -> Weight {
    with_transaction(|| {
        // your transactional function here

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.