如何将 AccountId 转换为 Vec<u8>,反之亦然

时间:2021-04-12 07:51:42

标签: substrate polkadot

我有一个接受 T::AccountId 类型的函数

    Citizen get(fn candidate_name): map hasher(blake2_128_concat) T::AccountId => Option<Vec<u8>>;

例如

    fn add_count(origin, account:T::AccountId, phrase: Vec<u8>) {
       // I need to concatenate : account + _ + phrase, then convert it to Vec<u8> or bytes
       // Then change the Citizen storage using account
    }

另一种方式是:

    fn add_count(origin, account:Vec<u8>, phrase: Vec<u8>) {
       // Concatenate : account + _ + phrase, then convert it to Vec<u8> or bytes
       // Then change account to T::AccountId and then change the Citizen storage
    }

但我无法将 T::AccountId 类型转换为 bytes/vec,反之亦然。

0 个答案:

没有答案