繁体   English   中英

如何获取和实施 wave 公钥

[英]How can I get and implement waves publickey

我的 JavaScript 代码出现错误,该代码正在从我的 Waves 钱包中请求公钥。 你们能帮我搞定吗? 这是阻止我的代码运行的唯一原因。 我需要公钥。

我这里有公钥,我只需要一种方法在我的 JavaScript 代码中实现它。

这是我部署后 Firebase 中的错误:

登录 Firebase:

来自已完成 function 的异常:错误:请提供种子或 senderPublicKey

在他们的 API 中显示: https://testnode1.wavesnodes.com/api-docs/index.html GET /addresses/publicKey/{public

这是链接: https://pastebin.com/AqswyjVC

    const functions = require('firebase-functions');
    exports.distributeStakingRewards = functions.pubsub.schedule('every 1 minutes').onRun((context) => {
        const request = require('request')
        //Fetch list of users who has a positive balance for your asset..
        const assetID = 'xxx'
     
        request('https://testnode1.wavesnodes.com/assets/' + assetID + '/distribution', function(err, res, body) {
            if (res.statusCode === 200) {
                const bodyJSON = JSON.parse(body)
                var transfers = []
                for (uid in bodyJSON) {
                    var bal = bodyJSON[uid]
                    //Set minimum balance to get rewarded
                    if (bal >= 1) {
                        var reward = '0.005'
                        var transfer = { recipient: uid, amount: reward }
                        transfers.push(transfer)
                    }
                }
                const waves = require('waves-transactions')
                const nodeUrl = 'https://testnode1.wavesnodes.com/'
                const params = { transfers: transfers,assetId: assetID, attachment: 'Weekly staking rewards payout', timestamp: Date.now() }
                const signedTx = waves.massTransfer(params,
                  {
                    'privateKey': 'xxxx',
                  }
                )
                const id = signedTx.id
                waves.nodeInteraction.broadcast(signedTx, nodeUrl).then(tx => {
                    //If tx returns null or undefined tx.id will be undefined === false
                    if (tx.id === id) {
                        console.log('Successfully distributed staking rewards for ' + new Date().toDateString() + 'was complete')
                    } else {
                        console.log('Unable to distribute staking rewards for ' + new Date().toDateString())
                    }
                })
            } else {
                console.log('unable to fetch asset distribution ' + err)
            }
        })
    })

Javascript

您需要在请求需要时传递publicKey 根据Swagger定义,它必须作为 URL 参数传递,如下所示:

let publicKey = 'your-public-key';

request('https://testnode1.wavesnodes.com/addresses/publicKey/' + publicKey, function(err, res, body) {

});

招摇UI

如果您想通过Swagger 接口测试请求,您可以在正确的请求下按下按钮Try it out ,用公钥填写所需的输入,然后按下按钮Execute

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM