交易所通過eosjs進(jìn)行充值與轉(zhuǎn)賬的代碼片段是怎樣的,很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來學(xué)習(xí)下,希望你能有所收獲。
成都創(chuàng)新互聯(lián),專注為中小企業(yè)提供官網(wǎng)建設(shè)、營銷型網(wǎng)站制作、響應(yīng)式網(wǎng)站設(shè)計、展示型成都做網(wǎng)站、成都網(wǎng)站建設(shè)等服務(wù),幫助中小企業(yè)通過網(wǎng)站體現(xiàn)價值、有效益。幫助企業(yè)快速建站、解決網(wǎng)站建設(shè)與網(wǎng)站營銷推廣問題。
連了兩個遠(yuǎn)程測試節(jié)點(diǎn)
const rpcUrl = 'http://jungle2.cryptolions.io:80'
const actionUrl = 'http://junglehistory.cryptolions.io:18888' //只找到這個測試節(jié)點(diǎn)能夠提供actions記錄
//處理賬戶交易記錄,判斷從上一次掃描之后賬戶新增記錄,并根據(jù)備注給用戶充值
async function dealActions(accountName) {
let rpcH = new JsonRpc(actionUrl, { fetch });
let actionHistory = await rpcH.history_get_actions(accountName);
let latestTime = 'select TRANS_TIME from RECHARGE where IFLAST=yes' //偽代碼
for (let i in actionHistory.actions) {
var block_time = actionHistory.actions[i].block_time
if(block_time > latestTime){
let memo = actionHistory.actions[i].action_trace.act.data.memo
let quantity = actionHistory.actions[i].action_trace.act.data.quantity
let from = actionHistory.actions[i].action_trace.act.data.from
let to = actionHistory.actions[i].action_trace.act.data.to
let trx_id = actionHistory.actions[i].action_trace.trx_id
let global_action_seq = actionHistory.actions[i].global_action_seq
let block_num = actionHistory.actions[i].block_num
let producer_block_id = actionHistory.actions[i].producer_block_id
//let to = actionHistory.actions[i].action_trace.act.data.to
console.log('memos'+i+'='+memo)
//insert into RECHARGE values() //插入充值表
//update USER_ACCOUNT set BALANCE AVAILABLE_BALANCE where USER_ID = 0 //更新賬戶
}
};
return actionHistory
}
//轉(zhuǎn)賬操作 轉(zhuǎn)賬到賬戶accountName 'eosaccountb2';轉(zhuǎn)賬數(shù)額quantity '1.1234 EOS'
async function transfer(accountName,quantity) {
let signatureProvider = new JsSignatureProvider([pkeys[0].privateKey]);
let api = new Api({ rpc, signatureProvider, textDecoder: new TextDecoder(), textEncoder: new TextEncoder() });
let result = await api.transact({
actions: [{
account: 'eosio.token',
name: 'transfer',
authorization: [{
actor: pkeys[0].actor,
permission: 'active',
}],
data: {
from: pkeys[0].actor,
to: accountName, //提現(xiàn)地址
quantity: quantity, //提現(xiàn)數(shù)量
memo: '',
},
}]
}, {
blocksBehind: 3,
expireSeconds: 30,
});
console.dir(result);
let transaction_id = result.transaction_id
let receipt= result.processed.receipt //抵押的net和cpu,記到數(shù)據(jù)庫備份
console.log('receipt===='+JSON.stringify(receipt))
//insert into WITHDRAW()
};
看完上述內(nèi)容是否對您有幫助呢?如果還想對相關(guān)知識有進(jìn)一步的了解或閱讀更多相關(guān)文章,請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對創(chuàng)新互聯(lián)的支持。
當(dāng)前題目:交易所通過eosjs進(jìn)行充值與轉(zhuǎn)賬的代碼片段是怎樣的
分享網(wǎng)址:http://muchs.cn/article8/gjgpop.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App設(shè)計、自適應(yīng)網(wǎng)站、網(wǎng)站維護(hù)、手機(jī)網(wǎng)站建設(shè)、標(biāo)簽優(yōu)化、定制開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)