1

I am not sure if this is the right forum to ask question related to PolkadotJS UI. Is there any way to render existing value in the extrinsic fields?

I have an extrinsic to update values in a storage. I want to show existing values to respective users so that they can update/remove.

At the moment, I don't see such option. I can only present an extrinsic, where user can enter value, that can be either inserted in existing collection or replace entire existing collection.

Can someone please help me to provide solution for this?

3
  • Hi! Yes, this is exactly the right place to ask this kind of questions. Not sure I understand the question, can you try to rephrase it or use an example of what you are looking for
    – Alex Bean
    Commented Feb 14, 2023 at 17:05
  • @AlexBean I have edited the description. Please let me know if you need any other detail
    – Boleng
    Commented Feb 15, 2023 at 5:43
  • it sounds like you just need to convert the extrinsic forms into "editable" extrinsic forms using a technique similar to that described here stackoverflow.com/a/66415622/3208553. read official docs about controlled components here reactjs.org/docs/forms.html#controlled-components Commented Feb 15, 2023 at 6:39

1 Answer 1

0

Yes, this is exactly the right place to ask this kind of questions.

I think what you want to achieve has to be done in the frontend part of your application.

Let's see it with an example:

We have in our chain the FRAME pallet Identity. This pallet has an extrinsic that set_identity (see here) that allows you to set an account's identity information. And it has another function kill_identity (see here) that allows an admin to remove an account's identity and sub-account information and slash the deposits.

If I understand correctly you would like for example to show in your all the existing values to the in order to make easy to pick the account that is going to be killed.

You can do that querying the state, for example:

const allEntries = await api.query.identity.identityOf.entries();
allEntries.forEach(([{ args: [accountId] }, identity]) => {
    console.log(`${accountId}`);
});

This will give you all the accounts Ids that has an identity registered.

From this information you must create in your app a dropdown that shows the user all the list of accounts that has an identity registered and let the user pick the account that want to kill. Then you can call the extrinsic with the account the user picked, in our example:

const killIdentity =api.tx.identity.killIdentity(accountId);
const tx = await killIdentity.signAndSend(pair);

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.