- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在从 PolkadotJS 生成一个公钥,如下所示
const keyring = new Keyring({ type: "sr25519" });
const account = keyring.addFromUri("//Bob", { name: "Bob default" });
// encoded public key
let public_key = keyring.encodeAddress(account.publicKey, 42);
console.log(public_key);
我正在添加 public_key
的类型作为"public_key": "Vec<u8>",
我正在从 Substrate 节点读取公钥,如下所示
// pk_raw is a Vec<u8> array
let pk = str::from_utf8(pk_raw.as_ref()).unwrap()
// the above returns `5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty`
我需要从这个值生成公钥。我尝试了以下内容
ed25519::Public::try_from(&*pk_raw).unwrap();
// above throws error since the data length is not equals to 32
fn try_from(data: &[u8]) -> Result<Self, Self::Error> {
if data.len() == 32 {
let mut inner = [0u8; 32];
inner.copy_from_slice(data);
Ok(Public(inner))
} else {
Err(())
}
}
有没有办法使用 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty
生成公钥?来自 Substrate Rust Side?
最佳答案
你可以这样使用:
use sp_core::crypto::Ss58Codec;
ed25519::Public::from_ss58check("5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty").expect("Valid address")
关于rust - 如何从 Substrate 端从 Polkadot 地址生成公钥,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70429492/
我尝试了 @polkadot/util-crypto lib 和 @polkadot/keyring 将公钥转换为 polkadot 地址,但没有帮助。 polkadot.js有没有提供什么方法?
我尝试了 @polkadot/util-crypto lib 和 @polkadot/keyring 将公钥转换为 polkadot 地址,但没有帮助。 polkadot.js有没有提供什么方法?
我正在使用@polkadot-js 设置 Nuxt.js 应用程序。当我使用我的@polkadot/types 请求自定义衬底运行时模块时 - 我收到此错误 Class constructor Str
Polkadot 有收割(杀死)账户余额低于存在阈值的概念。这个阈值是多少?在网络上执行收割过程以清除低余额账户的频率是多少? 最佳答案 一旦账户余额低于该阈值,收割就会发生。没有延迟,收获是减少余额
我想找到所有具有索引或已注册身份的 polkadot 帐户;类似于 https://polkascan.io/polkadot/account/identities和 https://polkasca
我正在从 PolkadotJS 生成一个公钥,如下所示 const keyring = new Keyring({ type: "sr25519" }); const account
我想使用 Substrate 链的基本单元格式化用户的余额。 当我使用 toHuman() 时,我会得到一个自以为是的格式,其中包含如下前缀: let account = await api.quer
我安装了以下 polkadot 包。 "@polkadot/api": "6.10.1", "@polkadot/extension-dapp": "0.41.1", "@polkadot/hw-le
在 Substrate 生态系统中,通常通过 fork Substrate Node Template 来开始编写新的区 block 链节点。 .用户界面有几个选项(例如 Apps 和 front-e
场景:您想要向您的自定义提交一个外部 Substrate节点 基于 substrate-node-template通过使用 Polkadot/Substrate frontend .您通过仔细搜索和替
我是一名优秀的程序员,十分优秀!