Substrate 如何将十六进制字符串转换为Vec<;u8>;

Substrate 如何将十六进制字符串转换为Vec<;u8>;,substrate,Substrate,我想将作为外部数据获得的十六进制字符串转换为托盘中的Vec。 出于这个原因,我尝试使用“hex::decode”,但我得到了以下编译错误,无法使用它。 你能告诉我一个解决方法或替代方法吗 我下面有错误 error: duplicate lang item in crate `sp_io` (which `pallet_offchain` depends on): `panic_impl`. | = note: the lang item is first defined in

我想将作为外部数据获得的十六进制字符串转换为托盘中的Vec。 出于这个原因,我尝试使用“hex::decode”,但我得到了以下编译错误,无法使用它。 你能告诉我一个解决方法或替代方法吗

我下面有错误

  error: duplicate lang item in crate `sp_io` (which `pallet_offchain` depends on): `panic_impl`.
    |
    = note: the lang item is first defined in crate `std` (which `hex` depends on)
    = note: first definition in `std` loaded from /Users/shin.takahashi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/libstd-38314f0df48bc600.rlib
    = note: second definition in `sp_io` loaded from /Users/shin.takahashi/develop/substrate/newest_node_template/substrate-node-template/target/release/wbuild/node-template-runtime/target/wasm32-unknown-unknown/release/deps/libsp_io-33eeda8e29be2065.rmeta

  error: duplicate lang item in crate `sp_io` (which `pallet_offchain` depends on): `oom`.
    |
    = note: the lang item is first defined in crate `std` (which `hex` depends on)
    = note: first definition in `std` loaded from /Users/shin.takahashi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/libstd-38314f0df48bc600.rlib
    = note: second definition in `sp_io` loaded from /Users/shin.takahashi/develop/substrate/newest_node_template/substrate-node-template/target/release/wbuild/node-template-runtime/target/wasm32-unknown-unknown/release/deps/libsp_io-33eeda8e29be2065.rmeta

  error: aborting due to 2 previous errors; 6 warnings emitted
fn get_decoded_address(address:&str)-> Vec<u8> {
    //value of address is like following. "0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d"
    hex::decode(&address).unwrap()
}
我的代码如下所示

  error: duplicate lang item in crate `sp_io` (which `pallet_offchain` depends on): `panic_impl`.
    |
    = note: the lang item is first defined in crate `std` (which `hex` depends on)
    = note: first definition in `std` loaded from /Users/shin.takahashi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/libstd-38314f0df48bc600.rlib
    = note: second definition in `sp_io` loaded from /Users/shin.takahashi/develop/substrate/newest_node_template/substrate-node-template/target/release/wbuild/node-template-runtime/target/wasm32-unknown-unknown/release/deps/libsp_io-33eeda8e29be2065.rmeta

  error: duplicate lang item in crate `sp_io` (which `pallet_offchain` depends on): `oom`.
    |
    = note: the lang item is first defined in crate `std` (which `hex` depends on)
    = note: first definition in `std` loaded from /Users/shin.takahashi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/libstd-38314f0df48bc600.rlib
    = note: second definition in `sp_io` loaded from /Users/shin.takahashi/develop/substrate/newest_node_template/substrate-node-template/target/release/wbuild/node-template-runtime/target/wasm32-unknown-unknown/release/deps/libsp_io-33eeda8e29be2065.rmeta

  error: aborting due to 2 previous errors; 6 warnings emitted
fn get_decoded_address(address:&str)-> Vec<u8> {
    //value of address is like following. "0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d"
    hex::decode(&address).unwrap()
}
fn获取解码地址(地址:&str)->Vec{
//地址值如下所示。“0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d”
十六进制::解码(&地址)。展开()
}
我必须正确编写“Cargo.toml”。下面是一个例子

rustc-hex = { version="2.1.0", default-features = false }

[features]
default = ['std']
std = [
    'rustc-hex/std',
]


我希望以字符串形式接收类似下面的AccountId,将其分配给调色板上的AccountId,然后将钱发送给该AccountId。“0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d”您需要导入带有
默认特性=false的
十六进制,然后将
hex/std
添加到您的托盘/运行时的
std
功能中。如果这个^^^有帮助,您可以自己发布它作为答案。谢谢您的帮助。它起作用了。很抱歉,我没有阅读基板的文档。我稍后再写答案。