I want to update staking_ledger from a custom pallet for migration of data from one chain to another, using method pallet_staking::Pallet::<T>::update_ledger but i am getting error that update_ledger is a private function, so how can I call a private function in migration pallet.

2 Answers 2


To make the pallet locally and update the visibility of the update_ledger function from pub (crate) to pub, you can follow these steps:

  • Locate the file where the update_ledger function is defined within
    your pallet. Change the visibility of the update_ledger function from pub (crate) to pub. This makes the function publicly accessible outside of the crate.

There is no way to call a private function unless you use unsafe and calculate the function address.

I think you could clone the Substrate repository and change that function to public. Then use cargo patch for this time.

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.