At the time of creating the user and keys, I need a way to add a field or fields related to this particular blockchain network, such as role. Is there a solution?
-
2Please provide more context. How are you creating these users? In a pallet? What are you trying to do that needs roles?– Bruno ♦Oct 21, 2022 at 16:27
-
@Bruno In fact, I want to have a role for each role of user so that I can limit a pellet methods to this roles.– Mehran MazharOct 22, 2022 at 14:25
-
Have you read about the origin system?– Nuke ♦Oct 28, 2022 at 7:25
1 Answer
So if you're building a pallet, you could have it update the frame system data
field in the AccountInfo
:
/// Information of an account.
#[derive(Clone, Eq, PartialEq, Default, RuntimeDebug, Encode, Decode, TypeInfo, MaxEncodedLen)]
pub struct AccountInfo<Nonce, AccountData> {
/// The number of transactions this account has sent.
pub nonce: Nonce,
/// The number of other modules that currently depend on this account's existence. The account
/// cannot be reaped until this is zero.
pub consumers: RefCount,
/// The number of other modules that allow this account to exist. The account may not be reaped
/// until this and `sufficients` are both zero.
pub providers: RefCount,
/// The number of modules that allow this account to exist for their own purposes only. The
/// account may not be reaped until this and `providers` are both zero.
pub sufficients: RefCount,
/// The additional data that belongs to this account. Used to store the balance(s) in a lot of
/// chains.
pub data: AccountData,
}
An example of a pallet that does this is pallet balances:
type AccountStore: StoredMap<Self::AccountId, AccountData<Self::Balance>>;
That is why when you look up an account on PolkadotJs Apps you will see the account balance information there as well.
If you're looking to add roles take a look at this post: