We have a pallet which has their own account e.g *b"replace_" and we are able to generate sub accounts addresses like so:
let sub_account: T::AccountId = T::PalletId::get().into_sub_account((0, 1))
In our react frontend, how can we fetch the address of a pallet's sub-account address using PolkadotJS API? (in this example the id is tuple of (0,1))
We set up the pallet account as detailed in Shawn's accepted answer: https://stackoverflow.com/questions/67082488/transferring-assets-between-accounts-and-pallet
and i found from this site https://www.shawntabrizi.com/substrate-js-utilities/ we can get the Pallet's account address using:
let address = stringToU8a(("modl" + moduleId).padEnd(32, '\0')); encodeAddress(address);
Our issue is getting the sub account address for a given id.