Skip to content

Conversation

@mdprana
Copy link

@mdprana mdprana commented Mar 13, 2025

In this FRAME Pallet Challenge, I implemented two core components of a Substrate blockchain. All tests passed successfully and showing that my code works correctly in different situations. It properly handles error cases like when someone tries to stake more tokens than they have or when they try to vote on a proposal that's already been finalized.

For the Governance Pallet:

  • Built an on-chain proposal and voting system
  • Made the Proposal<T> struct generic to properly store creator information
  • Added #[derive(Clone, PartialEq)] to the ProposalStatus enum for comparison operations
  • Implemented voting functionality with protection against double voting
  • Created methods to retrieve proposal details including descriptions and creators

For the Staking Pallet:

  • Created functionality to track both free and staked token
  • Implemented robust error handling using checked arithmetic operations
  • Added protection against overflows and underflows with checked_add and checked_sub
  • Wrote the code to properly handle insufficient balances during staking/unstaking

Implementation Details:

  • Used Rust's Result type for proper error handling across all operations
  • Employed pattern matching with if let and match for cleaner code
  • Implemented helper methods like get_proposal_details for easier data access
  • Made both pallets compatible with the same runtime configuration

image

@NTP-996
Copy link
Contributor

NTP-996 commented Mar 31, 2025

Look great, can you create pow on Discord so we can give you your reward?

@mdprana
Copy link
Author

mdprana commented Apr 4, 2025

Look great, can you create pow on Discord so we can give you your reward?

done sir 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants