I have implemented pallet_treasury
just like Kusama, how do i find the resulting address?
3 Answers
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
-
-
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
import { stringToU8a } from '@polkadot/util';
import { encodeAddress } from '@polkadot/util-crypto';
const treasuryAddress = encodeAddress(stringToU8a("modlpy/trsry".padEnd(32, '\0')))
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