我想请教个问题, 我用 polkadot api 来实现 dot 和 ksm 支付,参考的: https://polkadot.js.org/docs/api/examples/promise/make-transfer/,我从(Alice)转移给(Bob) 12345 ,页面中也可以查到这个事件,我这边转移给 Bob 的这个值:12345 ,是什么单位,如何换算成 dot 和 ksm 币?
1
Akagi201 2022-07-25 18:16:13 +08:00
|
3
railsboy OP @Akagi201 哈喽,另外我还想问下:
``` const wsProvider = new WsProvider('ws://127.0.0.1:9944'); const api = await ApiPromise.create({ provider: wsProvider }); const keyring = new Keyring({ type: 'sr25519' }); const alice = keyring.addFromUri('//Alice'); const BOB = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty'; api.tx.balances.transfer(BOB, amount * 1e10).signAndSend(alice) ``` 测试环境上 alice 转账给 BOB 是可以成功的,我真实转账如何设置呢? 是不是这里的 wsProvider 改成 wss://rpc.polkadot.io 呢,还有这里的 alice 我如何设置成自己的账号呢? 谢谢 |
4
railsboy OP 我看 alice 输出的内容是这样的
{ "address": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", "addressRaw": { "0": 212, "1": 53, "2": 147, "3": 199, "4": 21, "5": 253, "6": 211, "7": 28, "8": 97, "9": 20, "10": 26, "11": 189, "12": 4, "13": 169, "14": 159, "15": 214, "16": 130, "17": 44, "18": 133, "19": 88, "20": 133, "21": 76, "22": 205, "23": 227, "24": 154, "25": 86, "26": 132, "27": 231, "28": 165, "29": 109, "30": 162, "31": 125 }, "isLocked": false, "meta": {}, "publicKey": { "0": 212, "1": 53, "2": 147, "3": 199, "4": 21, "5": 253, "6": 211, "7": 28, "8": 97, "9": 20, "10": 26, "11": 189, "12": 4, "13": 169, "14": 159, "15": 214, "16": 130, "17": 44, "18": 133, "19": 88, "20": 133, "21": 76, "22": 205, "23": 227, "24": 154, "25": 86, "26": 132, "27": 231, "28": 165, "29": 109, "30": 162, "31": 125 } |
5
Akagi201 2022-07-28 01:03:49 +08:00
使用 keyring 这个包 https://polkadot.js.org/docs/keyring/start/ss58
|