1

Is it possible to add different role to the accounts? I mean some accounts can do more things on the chain than other. How it is possible to do?

2 Answers 2

1

If you describe what you're trying to build it may help for me to give you a more concise answer.

Generally speaking, if you're building a pallet you could have a StorageMap in that pallet that holds role -> account. Just keep in mind that storage and storage iteration is expensive on blockchains and it is preferred that you abstract the role to a layer higher than the blockchain (if you can).

Another common pattern in Substrate is to define an Origin in your pallet config that have designated permissions e.g. AdminOrigin and when you configure your pallet in the runtime, you set the AdminOrigin. Example here.

You can also create custom origins and do origin checks.

Nice video here covering custom origins on Pallet Collective.

Depending on what you're trying to achieve a SignedExtension may be the way to do it.

1

There are many ways to achieve this. Burno has mentioned one.

You can even do this without defining an origin.

For example, the pallet-staking: after calling bond(), you become a staker. If you call validate() afterwards, you become a validator. And if you call nominate() after that, you become a nominator.

Furthermore, you can check the pallet-identity's code. Once you become a identity registration merchant, you have the ability to authorize other accounts.

Basically, all you need to do is define a storage for storing those special accounts. Once a user makes a certain call, you can check if they are in the storage. If yes, then perform the desired action; if no, return an error indicating insufficient privileges.

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.