I use pallet account in my pallet.

pub const PALLET_ID: PalletId = PalletId(*b"abababab");
pub fn account_id() -> T::AccountId {

How can i get the pallet's account by polkadot.js app? Because i want to transfer some balance to the pallet's account.


1 Answer 1


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:

  1. prepend the "modl" prefix to your pallet id

     "modlabababab" = (in hex) => 6d6f646c6162616261626162
  2. zero pad the encoded byte array to 32 bytes

  3. prepend the network id (e.g. 0x2a for Substrate network)

  4. prepend the "SS58PRE" to the byte array computed in 3

     ("SS58PRE" = (in hex) => 53533538505245)
     => 535335385052452a6d6f646c61626162616261620000000000000000000000000000000000000000
  5. Compute the Blake2 hash of the byte array computed in 4

     $ echo 535335385052452a6d6f646c61626162616261620000000000000000000000000000000000000000 | xxd -ps -r | b2sum --length 512
  6. append the first two bytes of the Blake2 hash (i.e. the "checksum") to the string computed in 3

  7. convert to base 58

     $ echo 2a6d6f646c6162616261626162000000000000000000000000000000000000000070c3 | xxd -ps -r | base58

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


Shell script for the manual procedure

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
  • Thank you very much! i have got it.
    – bun
    Apr 28, 2022 at 14:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.