Esempio n. 1
0
def _validate(doc_hash, doc_name, pt=False):
    global data
    if pt:
        from pytezos import pytezos
        pytezos = pytezos.using(shell='testnet')
        ci = pytezos.contract('KT1DMYxvZCqSVcpea8t6xdVdoDRgPHY3x9sD')
    return data.get(doc_hash, {})
Esempio n. 2
0
def transferRewardsToContractDelegator(rewardEarners):
    for rewardee in rewardEarners:
        targetContract = pytezos.contract(rewardee['address'])
        op = targetContract.getRewardsFromBaker(None).with_amount(
            rewardee['amount']).operation_group.autofill().sign().preapply()
        op = targetContract.getRewardsFromBaker(None).with_amount(
            rewardee['amount']).operation_group.autofill().sign().inject(
                _async=False)
        print(op)
Esempio n. 3
0
def total_redeemed():
    """
    Check the total redeemed tokens from Fishcake Box
    """
    global pytezos, fishcake_box_addr
    try:
        fsck = pytezos.contract(fishcake_box_addr)
        tokensDistributed = fsck.storage()["tokensDistributed"]
        click.echo(f"\n[✓] Total Tokens Distributed : {tokensDistributed}\n")
    except Exception as e:
        click.echo(f"\n[!] Encountered Error : {str(e)}\n", err=True)
Esempio n. 4
0
def token_balance(address):
    """
    Check how many Fishcake Tokens user has

    ADDRESS is the address of the user
    """
    global pytezos, fishcake_token_addr
    try:
        fsck = pytezos.contract(fishcake_token_addr)
        balance = fsck.big_map_get(f"ledger/{address}")
        click.echo(f"\n[✓] User {address} Balance : {balance} FSCK\n")
    except Exception as e:
        if "not found" in str(e).lower():
            click.echo(f"\n[✓] User {address} Balance : 0 FSCK\n")
        else:
            click.echo(f"\n[!] Encountered Error : {str(e)}\n", err=True)
Esempio n. 5
0
def has_redeemed(address):
    """
    Check if user has redeemed tokens from Fishcake Box or not

    ADDRESS is the address of the user 
    """
    global pytezos, fishcake_box_addr
    try:
        fsck = pytezos.contract(fishcake_box_addr)
        fsck.big_map_get(f"users/{address}")
        click.echo(f"\n[✓] User {address} has redeemed the tokens\n")
    except Exception as e:
        if "not found" in str(e).lower():
            click.echo(f"\n[✓] User {address} has not redeemed the tokens\n")
        else:
            click.echo(f"\n[!] Encountered Error : {str(e)}\n", err=True)
Esempio n. 6
0
def setup(token_addr: str, box_addr: str) -> None:
    """
    Setup the contracts, perform initial mint of FSCK tokens and 
    fund the fishcake box contract
    """
    print(f"\nSetting up Contracts....")
    tokenContract = pytezos.contract(token_addr)
    print(f"-- Performing Initial Mint to Admin : {pub_key_hash}")
    tokenContract.initialMint(None).inject(_async=False)
    print("-- Funding Fishcake Box Contract")
    tokenContract.transfer([{
        "from_":
        pub_key_hash,
        "txs": [{
            "to_": box_addr,
            "token_id": 0,
            "amount": default_fsck_box_fund
        }]
    }]).inject(_async=False)
Esempio n. 7
0
 def setUpClass(cls):
     cls.fa12 = ContractInterface.create_from(
         join(project_dir, 'samples/fa1.2.tz'))
     cls.viewer = pytezos.contract(viewer_address)
     cls.maxDiff = None
Esempio n. 8
0
 def setUpClass(cls):
     cls.atomex = ContractInterface.create_from(
         join(project_dir, 'src/atomex.tz'))
     cls.fa12 = pytezos.contract(fa_address)
     cls.maxDiff = None
Esempio n. 9
0
#       uses about 5x the required transaction fees. You
#       might want to look into how to predict better fees.
def send_transaction(contract, nonce, solution):
    return contract.default(nonce, solution).operation_group.inject()


############## STUFF YOU NEED TO ENTER #######################
base58key = '<base58 private key>'  # Your base58 encrypted private key
address_bytes = bytes.fromhex(
    "<hex address string>")  # Produced in ligo script
contract_address = 'KT1Udix7b2UUnnqSzAk6JsqDy7m1ecwTG1LB'  # The contract address
##############################################################

pytezos = pytezos.using(shell='https://mainnet-tezos.giganode.io',
                        key=base58key)
contract = pytezos.contract(contract_address)

challenge_bytes = get_challenge(contract)
min0s = "0" * min_0s_for_prize(contract)

print('running with challenge:', challenge_bytes.hex())
print('current difficulty:', min0s)

while True:
    # Pick a random number
    nonce_bytes = random.randbytes(16)

    # Generate a solution hash
    tohash = challenge_bytes + nonce_bytes + address_bytes
    solution = hashlib.blake2b(tohash, digest_size=32).hexdigest()
Esempio n. 10
0
from flask import Flask, request, jsonify, session
from pytezos import pytezos
# import pymongo
from flask_cors import CORS, cross_origin
from hashlib import sha256
from datetime import datetime
from .config import config

pytezos = pytezos.using(
    key=config['TEZOS_KEY'])

contract = pytezos.contract(config['CONTRACT'])

app = Flask(__name__)
CORS(app, supports_credentials=True)
app.secret_key = config['SECRET_KEY']
app.config.update(SESSION_COOKIE_SAMESITE="None", SESSION_COOKIE_SECURE=True)

# mongoCluster = pymongo.MongoClient(config['DATABASE_URL'])
# db = mongoCluster.db
# usersCollection = db.users
# superuserCollection = db.superuser

@app.route("/")
def index():
    return "<h1>Hello World!</h1>"

@app.route("/user", methods=["GET", "POST"])
@cross_origin(supports_credentials=True)
def usersView():
    if request.method == "POST":
Esempio n. 11
0
    def get(self):

        ci = pytezos.contract(request.args.get('kt', ''))

        return ci.storage()