小编s.T*_*shi的帖子

如何在 Substrate 上保存字符串值

  1. 我想在基板上保存“字符串”值
  2. 起初,我使用“Vec”但它不被 Polkadot JS 识别
  3. 我使用“字节”,所以我收到以下错误
  4. 我怎么解决这个问题?

请帮我。

  • 使用“字节”作为存储字符串的方式是否正确?
  • 如果正确,我该如何修复下面的错误?
  • 如果不是,正确使用什么?
  • 如果您有示例代码,请告诉我
#[cfg(test)]
mod mock;

#[cfg(test)]
mod tests;

#[derive(Clone, Eq, PartialEq, Default, Encode, Decode, Hash)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
pub struct TestData<BlockNumber,Bytes> {
    pub name: Bytes,                                                                                                                                                                    
    pub address: Bytes,
}
pub type TestDataOf<T> = TestData<primitives::Bytes>;
--snip--
// This pallet's storage items.
decl_storage! {
    // It is important to update your storage name so that your pallet's
    // storage items are isolated from other pallets.
    // ---------------------------------vvvvvvvvvvvvvv
    trait Store …
Run Code Online (Sandbox Code Playgroud)

substrate

3
推荐指数
1
解决办法
571
查看次数

标签 统计

substrate ×1