In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Exchange through eosjs recharge and transfer code snippet is how, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
Two remote test nodes are connected
Const rpcUrl = 'http://jungle2.cryptolions.io:80'
Const actionUrl = 'http://junglehistory.cryptolions.io:18888' / / only this test node can provide actions records
/ / process the account transaction records, determine the new account records after the last scan, and recharge the user according to the remarks
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' / / pseudo code
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] .activities _ block_id
/ / let to = actionHistory.actions [I] .action _ trace.act.data.to
Console.log ('memos'+i+'='+memo)
/ / insert into RECHARGE values () / / insert the recharge table
/ / update USER_ACCOUNT set BALANCE AVAILABLE_BALANCE where USER_ID = 0 / / Update the account
}
}
Return actionHistory
}
/ / transfer operation transfer to account accountName 'eosaccountb2'; transfer amount 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, / / withdrawal address
Quantity: quantity, / / number of withdrawals
Memo:''
}
}]
}, {
BlocksBehind: 3
ExpireSeconds: 30
});
Console.dir (result)
Let transaction_id = result.transaction_id
Let receipt= result.processed.receipt / / net and cpu of the mortgage, recorded in the database backup
Console.log ('receipt===='+JSON.stringify (receipt))
/ / insert into WITHDRAW ()
}
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.