4

I have implemented pallet_treasury just like Kusama, how do i find the resulting address?

1

3 Answers 3

4

Find the pallet id in runtime first. Different networks might use different id. Kusama treasury pallet id

Use subalfred.

λ subalfred key 'py/trsry' --key-type pallet --network kusama
public-key 0x6d6f646c70792f74727372790000000000000000000000000000000000000000 PalletId(py/trsry)
kusama F3opxRbN5ZbjJNU511Kj2TLuzFcDq9BGduA9TgiECafpg29

https://kusama.subscan.io/account/F3opxRbN5ZbjJNU511Kj2TLuzFcDq9BGduA9TgiECafpg29

2
  • Can I use this tool for a custom Substrate chain?
    – Bruno
    Commented Aug 18, 2022 at 0:41
  • Sure. It use the same algorithm as substrate. —network just change the ss58 prefix. public key is the same.
    – aurexav
    Commented Aug 18, 2022 at 3:15
4
import { stringToU8a } from '@polkadot/util';
import { encodeAddress } from '@polkadot/util-crypto';

const treasuryAddress = encodeAddress(stringToU8a("modlpy/trsry".padEnd(32, '\0')))
1

Here's another using just subkey:

$ HEX=$(printf "modlpy/trsry" | xxd -p)
$ PUBLIC_KEY=$(printf 0x%-64s $HEX | tr " " 0)
$ subkey inspect $PUBLIC_KEY --network kusama --public
Network ID/Version: kusama
  Public key (hex):   0x6d6f646c70792f74727372790000000000000000000000000000000000000000
  Account ID:         0x6d6f646c70792f74727372790000000000000000000000000000000000000000
  Public key (SS58):  F3opxRbN5ZbjJNU511Kj2TLuzFcDq9BGduA9TgiECafpg29
  SS58 Address:       F3opxRbN5ZbjJNU511Kj2TLuzFcDq9BGduA9TgiECafpg29

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.