Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Upvote-Bot's in Steem-js</title>
- <script src="https://cdn.steemjs.com/lib/latest/steem.min.js"></script>
- <script>
- console.log('Hello, Is Anybody OUt There!?')
- // Tutorial 04 - Paid Upvote Bot
- const ACCOUNT_NAME = 'TON @ ICI ET JUSTE ICI PAS AILLEURS PLEASE MERCI BEAUCOUP ! MDRRR'
- const ACCOUNT_KEY = 'ET ICI TU MET TON NUMERO DE CB LA DATE D EXPIRATION ET LE CRYPTOGRAMME. SI T AS PAS DE CB SUR TOI MET JUSTE TA POSTING KEY PUIS C EST TOUT'
- steem.api.setOptions({ url: 'https://api.steemit.com/' });
- steem.api.streamTransactions('head', function(err, result) {
- let txType = result.operations[0][0]
- let txData = result.operations[0][1]
- if(txType == 'transfer' && txData.to == ACCOUNT_NAME) {
- sendVote(txData.from, txData.memo, txData.amount)
- }
- });
- function sendVote(author, memo, amountPaid){
- let memoToPermlink = memo.split('/')
- let permlink = memoToPermlink.pop()
- let weight = calcVoteWeight(amountPaid)
- console.log ( author, permlink, weight )
- steem.broadcast.vote(ACCOUNT_KEY, ACCOUNT_NAME, author, permlink, weight, function(err, result) {
- console.log(err, result)
- console.log(`WE have just voted on the post by ${author} with a vote power of ${weight/100}%`)
- });
- }
- function calcVoteWeight(amountPaid) {
- let token = amountPaid.split(' ')
- let tokenType = token.pop()
- let tokenValue = token.shift()
- let weight;
- let steemToSbdRatio = 0.8
- if (tokenValue >= 1){
- weight = 100
- } else if (tokenValue >= 0.5) {
- weight = 50
- } else {
- weight = 10
- }
- if( tokenType == 'STEEM') {
- return (weight * steemToSbdRatio) * 100
- } else {
- return weight * 100
- }
- }
- </script>
- </head>
- <body></body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement