Php site for Bid Bot (Part 1) - Calculate Vest of all Steem Delegators and give the possibility to new users to delegate Vest on your Bot - Ubuntu 16.04

in #utopian-io6 years ago (edited)

Preview

preview.png

Description

If you have your own Bid Bot, you are probably looking for more delegation.
This script is the First part of a Full Guide.

My Bid Bot for Minnows is @astrobot.
Read more on this article: https://steemit.com/astrobot/@astrobot/introducing-astrobot-a-new-bidding-upvote-bot

This source Code, It's a PHP code integrated with Python for STEEM Blockchain and used for:

  • Permit users to delegate Steem Power - To Your BOT
  • Permit everyone to check who is delegating Vest to Your BOT and how Much

In the second part we will calculate proportionally how much every users should earn, based on the Slogan Schema:

The Bot Slogan

You can earn daily passive income by delegating your Steem Power (Vest) to @astrobot and You can undelegate your SP anytime you want (it takes one week)

How much will I earn?

It depends on your SP contribution and how much the bot has earned on previous day. The bot distributes 80% rewards to all delegators next next day. Consider this scenary example: There are two delegators - 'Pippo' & 'Pluto'.
Pippo delegated 900 VP & Pluto delegated 100 VP: Astrobot VP is 1000 VP

Pippo delegated 90% of Total Astrobot VP & Pluto delegated 10% of Total Astrobot VP

Astrobot earned $100 SBD on previous day. Next day it is going to distribute the 80% of $100 SBD to all delegators.

Pippo will receive the 90% of 80% earned by astrobot & Pluto will receive the 10% of 80% earned by astrobot

Pippo will receive $72 SBD & Pluto will receive $8 SBD

If the bot earns no money on previous day, nobody will get paid on the following day.

Requirements:

  • Apache2 modules
  • Php modules
  • Python 3

Install Requirements:

APACHE2:

sudo apt-get update sudo apt-get install apache2 sudo ufw allow 'Apache Full' sudo systemctl status apache2 sudo systemctl enable apache2

PHP:

sudo apt-get install -y php7.0 libapache2-mod-php7.0 php7.0-cli php7.0-common php7.0-mbstring php7.0-gd php7.0-intl php7.0-xml php7.0-mysql php7.0-mcrypt php7.0-zip sudo systemctl restart apache2.service

PYTHON3:

sudo add-apt-repository ppa:jonathonf/python-3.6 sudo apt update sudo apt install python3.6

Script Components:

https://github.com/yanosh01/Steem-Power-calculator-and-delegator-on-PHP.git

  • Index.php
  • Delegator.py
  • astrobot.jpg

Source Code:

Thanks to @twinner for this Python source code:

https://steemit.com/steemdata/@twinner/2-python-scripts-for-steemdata-to-get-a-list-of-all-steempower-delegators-or-delegatees-for-a-specific-account

I'll rewrite it for give users the possibility to have the code complete

Delegator.py

from steemdata import SteemData
from collections import Counter
import sys

s = SteemData()

delegations = s.Operations.find( {
    '$and': [
        {'type' : 'delegate_vesting_shares'},
        {'delegatee': sys.argv[1]}
    ]
} )             

delegation_map = dict()

for delegation in delegations:
    delegator = str(delegation['delegator'])
    vestings = delegation['vesting_shares']
    amount = vestings['amount']
    delegation_map[delegator] = amount

i=1

for key in sorted(delegation_map):
    if delegation_map[key] > 0:
        print('|' + str(i) + '|' + key + '|' + str(delegation_map[key])+ '|')
        i += 1


Index.php

<html>
<body>
<script>
function process()
{
var url="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=" + document.getElementById("url").value +"&delegatee=astrobot&vesting_shares="+document.getElementById("steempower").value +"%20VESTS";
location.href=url;
return false;
}
</script>

<form onSubmit="return process();">
<center>
<h2 style="color:Black;"> Welcome to <a href="https://steemit.com/@astrobot">@astrobot</a> Delegation service. </h2><p>
<center><img src="/images/astrobot.jpg">
</p>
<p>
</p>
You can earn daily passive income by delegating your Steem Power (Vest) to <a href="https://steemit.com/@astrobot">@astrobot</a>. However You can undelegate your SP anytime you want (it takes one week)

<h2 style="color:Black;"> How much will I earn?</h2>
It depends on your SP contribution and how much the bot has earned on previous day. The bot distributes 80% rewards to all delegators next next day. 
Consider this scenary example:
There are two delegators - 'Pippo' & 'Pluto'.
<p>
Pippo delegated 900 VP & Pluto delegated 100 VP: Astrobot VP is 1000 VP
<p>
<p>
Pippo delegated 90% of Total Astrobot VP & Pluto delegated 10% of Total Astrobot VP
<p>
<p>
Astrobot earned $100 SBD on previous day.
Next day it is going to distribute the 80% of $100 SBD to all delegators. 
<p>
<p>
Pippo will receive the 90% of 80% earned by astrobot & Pluto will receive the 10% of 80% earned by astrobot
<p>
<p>
Pippo will receive $72 SBD & Pluto will receive $8  SBD
<p>
<p>

If the bot earns no money on previous day, nobody will get paid on the following day.
<p>
<hr>
<p>
Select The Amount Of Steem Power You Wish To Delegate and Enter Your Steemit Username Below To Get Started.</p>
Select Amount Of Steem Power To Delegate: 
<select id="steempower">
<option value="51376.58419">25 Steem Power</option>
<option value="102753.16839">50 Steem Power</option>
<option value="205506.33678">100 Steem Power</option>
<option value="411012.67356">200 Steem Power</option>
<option value="1027530.168390">500 Steem Power</option>
<option value="2055060.336780">1000 Steem Power</option>
</select>
</br>
Enter Steemit Username:<input type="text" name="url" id="url"> <input type="submit" value="Delegate Now">

</center>
</form>
<p>
<h2>This service use Steemconnect for authenticate users and does not store any passwords</h2>

<hr>
This is the list of Delegator and their Vest:
<p>

<?php
$output = shell_exec("python3 delegator.py astrobot");
echo nl2br($output);
?>


</body> 
</html>

How to start the project?

Copy files into folder /var/www/html and edit index.PHP as you need

Explanation

The file Delegator.py is used to calculate who is delegating Vest. To integrate into php code we use:

deleg.png

Php part to run the python script and print output on web page:

<? php
$output = shell_exec("python3 delegator.py astrobot");
echo nl2br($output);
?>

nl2br tell to wordwrap output.
Change "astrobot" with the username of your bot

This is the form where you can delegate SP based on Predefined Value

howmuch.png

var url="https://v2.steemconnect.com/sign/delegateVestingShares?delegator=" + document.getElementById("url").value +"&delegatee=astrobot&vesting_shares="+document.getElementById("steempower").value +"%20VESTS";

This variable is used to delegate vest based on the form field you insert.
Remember to change astrobot with your bot

All the rest is like the HTML code

Remember to upvote me as your Witness and to Join on my discord channel

https://steemit.com/~witnesses

DQmbVGHGMJNhUpmqUTeDvvMGaevzaNFdib24Sa9XhVS48XM.gif



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Details and easy to understanding.... Let me resteem this post for infomation to my frienda

thanks for reading... I hope it wiil help people!!!

Congratulations! This post has been upvoted from the communal account, @minnowsupport, by Yanosh01 from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, theprophet0, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows. Please find us at the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.

If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP.
Be sure to leave at least 50SP undelegated on your account.

Thanks for this. it's really a useful tip.
I will get back to you.

Ty, you are welcome!!!

Your contribution cannot be approved because it is not as informative as other contributions. See the Utopian Rules. Contributions need to be informative and descriptive in order to help readers and developers understand them.

You can contact us on Discord.
[utopian-moderator]

Coin Marketplace

STEEM 0.23
TRX 0.12
JST 0.029
BTC 66708.32
ETH 3471.95
USDT 1.00
SBD 3.18