簡體   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