微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在底物中生成随机数?

如何解决如何在底物中生成随机数?

大家好,有可能使用rand crate在基板上生成一个随机数吗?

因为我将其导入到Cargo.toml文件

[dependencies.rand] 
version = '0.7.3' 

它给我以下错误

duplicate lang item in crate `std` (which `rand` depends on): `panic_impl`.
  |
  = note: the lang item is first defined in crate `sp_io` (which `frame_support` depends on)
  = note: first deFinition in `sp_io` loaded from /home/noone/powattem/substrate-node-template/target/release/wbuild/target/wasm32-unkNown-unkNown/release/deps/libsp_io-335dca76a9d63bdd.rMeta
  = note: second deFinition in `std` loaded from /home/noone/.rustup/toolchains/nightly-x86_64-unkNown-linux-gnu/lib/rustlib/wasm32-unkNown-unkNown/lib/libstd-023ef8617de52e0e.rlib

解决方法

节点模板包括the Randomness Collective Flip pallet,该模板实现了the Randomness trait。您似乎要导入的板条箱似乎具有union依赖性,在必须编译为Wasm的Substrate运行时中将无法使用。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。