I'm trying to learn how to use the staking pallet in a game I'm building as a way to learn substrate, linked here, and I'd like to implement staking an amount when challenging another player. However, I'm using Frame 4.0.0-dev, and I'm unable to find enough resources to help me understand how to mock BalanceOf for writing tests. Could someone point me to some? I've been looking at lockable currency, but that pallet doesn't have any tests.

Could someone help me here?

2 Answers 2


In your mock.rs file at the very end you are building the mock storage with pub fn new_test_ext(). In there, you can use pallet_balances to predefine some balances for your addresses along the lines of:

pub fn new_test_ext() -> sp_io::TestExternalities {
    let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
    pallet_balances::GenesisConfig::<Test> {
        balances: vec![(1, 100_000), (2, 100_000), (3, 100_000), (4, 100_000), (5, 100_00)],
    .assimilate_storage(&mut t)

Also add Balances: pallet_balances to construct_runtime! .


Where are you going to use the BalanceOf?

I think you could take a look at the pallet-balances. It shows you:

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.