I don't know if you can do it directly using polkadot.js but I can suggest you a couple of ways to obtain the account id you are looking for.
The easy way
Just write a trivial Rust program that uses the Substrate API to get what you want:
use frame_support::PalletId;
use sp_runtime::{MultiSignature, traits::{AccountIdConversion, IdentifyAccount, Verify}};
type AccountId = <<MultiSignature as Verify>::Signer as IdentifyAccount>::AccountId;
let pallet_id = PalletId(*b"abababab");
let acc: AccountId = pallet_id.into_account();
println!("{}", acc.to_string());
The manual way
This is if you are curious about understanding what is going on under to hood...
Given the pallet id: "abababab"
, to manually reproduce what the into_account
method is doing:
prepend the "modl"
prefix to your pallet id
"modlabababab" = (in hex) => 6d6f646c6162616261626162
zero pad the encoded byte array to 32 bytes
6d6f646c61626162616261620000000000000000000000000000000000000000
prepend the network id (e.g. 0x2a for Substrate network)
2a6d6f646c61626162616261620000000000000000000000000000000000000000
prepend the "SS58PRE"
to the byte array computed in 3
("SS58PRE" = (in hex) => 53533538505245)
=> 535335385052452a6d6f646c61626162616261620000000000000000000000000000000000000000
Compute the Blake2 hash of the byte array computed in 4
$ echo 535335385052452a6d6f646c61626162616261620000000000000000000000000000000000000000 | xxd -ps -r | b2sum --length 512
70c39bed485b02f21d07be4de45946492f0177bb5663b3018fe5714fc8d014705c94ed4d7cae0b92ed9c141c298a2d72264fc87700f223dd94ccc6bf9202b025
append the first two bytes of the Blake2 hash (i.e. the "checksum") to the string computed in 3
2a6d6f646c6162616261626162000000000000000000000000000000000000000070c3
convert to base 58
$ echo 2a6d6f646c6162616261626162000000000000000000000000000000000000000070c3 | xxd -ps -r | base58
5EYCAe5fiMgHBR7cyJUzU6YLj8uRjgHZrkt2VJxW5cjSHSYi
Your account id is 5EYCAe5fiMgHBR7cyJUzU6YLj8uRjgHZrkt2VJxW5cjSHSYi
Note: if you don't have the base58
tool installed you can always use an online tool such as this (select "hex" input).
Using Subkey
Once you have the byte array computed in point 3 of the "manual way" you can pass it directly to subkey
tool
$ subkey inspect --public 6d6f646c61626162616261620000000000000000000000000000000000000000
Network ID/version: substrate
Public key (hex): 0x6d6f646c61626162616261620000000000000000000000000000000000000000
Account ID: 0x6d6f646c61626162616261620000000000000000000000000000000000000000
SS58 Address: 5EYCAe5fiMgHBR7cyJUzU6YLj8uRjgHZrkt2VJxW5cjSHSYi
Bonus
Shell script for the manual procedure
#!/bin/bash
pre=$(printf "modl"$1 | xxd -ps)
pre=$(printf "2a%-64s" $pre | sed 's/ /0/g')
to_hash=$(printf "53533538505245"$pre)
checksum=$(echo $to_hash | xxd -ps -r | b2sum --length 512 | cut -c 1-4)
echo $pre$checksum | xxd -ps -r | base58
Call it as:
$ ./<thescriptname> abababab
5EYCAe5fiMgHBR7cyJUzU6YLj8uRjgHZrkt2VJxW5cjSHSYi