import requests
import sys
import random
import string
import hashlib
from pprint import pprint
import cfscrape
import subprocess

# pip install git+https://github.com/eosnewyork/eospy
import eospy.cleos
import eospy.keys

ACCOUNT = '...........'
AMOUNT = '0.1000 EOS'
# 3 - 96
UNDER = 96

session = requests.session()
session.headers = {
    'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/530.36 (KHTML, like Gecko) Chrome/70.0.3508.77 Safari/507.36',
}

scraper = cfscrape.create_scraper(sess=session)
print(scraper.get("https://eosjacks.com").content)


def generate_user_seed():
    seeds = string.ascii_letters + string.digits + ' '
    return ''.join(random.sample(seeds, 40))

def start_dice(under = 96):
    payload = {"roll_under": under}
    url = "https://eosjacks.com/dice/start"

    resp = scraper.post(url, json=payload)
    payload = resp.json()

    return payload


def get_memo(under=96):
    user_seed = generate_user_seed()
    user_seed_hash = hashlib.sha1(user_seed.encode()).hexdigest()
    dice = start_dice(under)

    return '{}-{}-{}-{}-{}'.format(
        under,
        dice['house_hash'],
        user_seed_hash,
        dice['expiration_time'], # game_at
        dice['house_sign']
    )


cleos = eospy.cleos.Cleos(url='https://geo.eosasia.one')

def transfer(from_, to_, quantity, memo):
    # https://github.com/eosnewyork/eospy/blob/master/examples/push_transaction.py
    payload = [
        {
            'args': {
                "from": from_,
                "to": to_,
                "quantity": quantity, # '1.0000 EOS',  # In EOS
                "memo": memo,
            },
            "account": "eosio.token",
            "name": "transfer",
            "authorization": [{
                "actor": from_,
                "permission": "active",
            }],
        }
    ]
    data = cleos.abi_json_to_bin(payload[0]['account'], payload[0]['name'], payload[0]['args'])
    payload[0]['data'] = data['binargs']
    payload[0].pop('args')
    trx = {"actions":[payload[0]]}

    # NOTE: never works
    raise SystemExit('eospy sucks')
    pprint(trx)
    PRIV_KEY = '...............................'
    key = eospy.keys.EOSKey(PRIV_KEY)
    resp = cleos.push_transaction(trx, key, broadcast=True)
    print('------------------------------------------------')
    print(resp)
    print('------------------------------------------------')


def main():
    memo = get_memo(UNDER)
    print(memo)
    transfer(ACCOUNT, 'eosjacksdice', AMOUNT, memo)


def fuck_you():
    memo = get_memo(UNDER)
    print(memo)
    out = subprocess.check_output(
        'opt/eosio/bin/cleos -u https://geo.eosasia.one transfer {} eosjacksdice "{}" {}'.format(ACCOUNT, AMOUNT, memo),
        stderr=subprocess.STDOUT,
        shell=True)
    print(out.decode())


if __name__ == '__main__':
    while 1:
        fuck_you()
  • 0