6

The ensure_signed function of pallets/template/lib.rs contains a parameter named origin of type OrginFor<>. I have been looking inside various projects and all I see is doing ensure_signed(origin)?.

My question is how actually should I get something like public key or wallet address from that origin value. I believe something must be inside Signed(AccountId) variant. But in test files of several examples and tutorials all i see is they simply pass Origin::Signed(1). What am I supposed to do with that 1?

I am pretty starting out in these blockchain things so any kind of knowledge is highly appreciated

Sudip Ghimire
  • 677
  • 6
  • 15
  • 1
    The `ensure_signed` function returns an `AccountId`, aka Public key. Test use `Origin::Signed(1)` to create a mocked origin for `AccountId` 1. Edit for pressing Enter too early. – Oliver Tale-Yazdi Jan 02 '22 at 15:01
  • So in runtime I will get some public key inside Signed instead of just 1? – Sudip Ghimire Jan 03 '22 at 06:38
  • 1
    Yes for example [here](https://github.com/perun-network/perun-polkadot-pallet/blob/39a6176cb4a78aac329bddd6d9dc8b307b03fea7/src/lib.rs#L225) you can see that `who` is an `AccountId` and is later used to transfer funds from. – Oliver Tale-Yazdi Jan 03 '22 at 12:56
  • As you said, given that who is an AccountId, who can I compare it to some other source (vec/array of u8 in my case) to see if the who and that source are same. – Sudip Ghimire Jan 13 '22 at 05:00

0 Answers0