0

I am working on a Substrate-based blockchain using the Frontier template to achieve Ethereum compatibility. I am looking to synchronize the balance states between the EVM pallet and Substrate's native balances to ensure consistency across both environments. My goal is to have every transaction affecting balances reflect accurately in both the EVM and the native Substrate state.

Current Setup:

I have set up the genesis block with predefined balances in both the EVM and Substrate environments.

My node is configured with both Ethereum and Substrate runtime modules. Issue:

  1. I am unsure how to ensure that any balance update in the EVM is reflected in the Substrate balance and vice versa.

2 . I am looking for a way to implement hooks or listeners in the runtime that can handle these cross-pallet communications efficiently. Questions:

How should I configure the genesis block in chain_spec.rs to initialize balances that are recognized by both the EVM and Substrate systems?

What is the recommended way to implement runtime logic to keep the EVM and Substrate balances synchronized?

Are there any examples or best practices I can follow to ensure robust and secure synchronization?

Any guidance or references to documentation would be greatly appreciated. Thank you!

1 Answer 1

0

if you are using frontier's pallet-evm, it has a Currency type in its' configuration. So, if you pass the Balances to it you will have a single source of truth for balances in that pallet.

How should I configure the genesis block in chain_spec.rs to initialize balances that are recognized by both the EVM and Substrate systems?

you can pass the initial balances of evm accounts in the accounts field of fp_evm::GenesisAccount. See example here.

I am looking for a way to implement hooks or listeners in the runtime that can handle these cross-pallet communications efficiently.

I don't think this is necessary. As mentioned above, just pass Balances to pallet_evm::Config

1
  • Thank you so much for your answer! Since posting this I have learned so much about substrate and this has been resolved, but thank you nonetheless! Commented 8 hours ago

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.