1

I am currently looking at the assets pallet and I don't really understand what the touch method does. Hope someone can explain it to me. Thanks!

1 Answer 1

4

In short, the touch method creates a new "Asset Account" for the "User Account".

I suspect that the touch name comes from the unix command called 'touch' which creates a new file if it does not exist already. (sort of, don't worry about it).

In the v4.0.0-dev source for the asset pallet, you can see in the lib.rs that Touch calls do_touch, which we can find in functions.rs.

If we look at that do_touch function, we can see that it checks if the "User Account" already has an entry for the "Asset Account", and if it does not it inserts a new "Asset Account" for the "User Account".

1
  • I am not totally sure if the function name comes from the Unix command touch because it is actually a command that updates the last time modified field of a file, but yeah it can be used to create new files. Anyway, it isn't really important where the name comes from. Thanks for the clarification!
    – Szegoo
    Commented Apr 14, 2022 at 6:33

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.