def buy_copyright(copyright, address):
    copyright = sha256(copyright)
    if check_owner(copyright):
        return False
    owner_adr = get_owner(copyright)

    Notify(['buy', copyright, address])

    param = state(address, owner_adr, 10)
    OntContract = ToScriptHash("AFmseVrdL9f9oyCzZefL9tG6UbvhUMqNMV")

    res = Invoke(0, OntContract, "transfer", [param])
    if res != b'\x01':
        raise Exception("transfer ont error.")
    Notify("transferONT succeed")
    return put_grants(copyright, address, 120)
Ejemplo n.º 2
0
def deploy():
    Require(CheckWitness(admin_))

    # Set admin
    admin_key = concatKey(admin_, ADMIN_SUFFIX)
    Put(GetContext(), admin_key, True)

    # Set managers
    manager1 = ToScriptHash("AQf4Mzu1YJrhz9f3aRkkwSm9n3qhXGSh4p")
    key = concatKey(manager1, MANAGER_SUFFIX)
    Put(GetContext(), key, True)
    #  can add manager2, 3, 4, 5, 6

    # set anti early whale key as true for the early stage
    Put(GetContext(), ANTI_EARLY_WHALE_KEY, True)
    # initiate totalSupply
    Put(GetContext(), TOTAL_SUPPLY_KEY, 0)

    # initiate pricePerToken
    Put(GetContext(), PRICE_PER_TOKEN_KEY, 0)

    return True
Ejemplo n.º 3
0
from boa.interop.System.Storage import GetContext, Get, Put, Delete
from boa.interop.System.Runtime import Notify, CheckWitness
from boa.interop.System.Action import RegisterAction
from boa.builtins import concat, ToScriptHash
# from boa.interop.Ontology.Runtime import AddressToBase58, Base58ToAddress

TransferEvent = RegisterAction("transfer", "from", "to", "amount")
ApprovalEvent = RegisterAction("approval", "owner", "spender", "amount")

ctx = GetContext()

NAME = 'Aesop'
SYMBOL = 'AES'
DECIMALS = 8
FACTOR = 100000000
OWNER = ToScriptHash("AabYzjuPMm42KTcWtZQ9qMZ3bc2Mxp2EQW")
# OWNER = bytearray(b'\x61\x6f\x2a\x4a\x38\x39\x6f\xf2\x03\xea\x01\xe6\xc0\x70\xae\x42\x1b\xb8\xce\x2d')
TOTAL_AMOUNT = 1000000000
BALANCE_PREFIX = bytearray(b'\x01')
APPROVE_PREFIX = b'\x02'
SUPPLY_KEY = 'TotalSupply'


def Main(operation, args):
    """
    :param operation:
    :param args:
    :return:
    """
    # 'init' has to be invokded first after deploying the contract to store the necessary and important info in the blockchain
    if operation == 'init':
Ejemplo n.º 4
0
from boa.interop.Ontology.Contract import Migrate
from boa.interop.System.Storage import GetContext, Get, Put, Delete
from boa.interop.System.Runtime import CheckWitness, GetTime, Notify, Serialize, Deserialize
from boa.interop.System.ExecutionEngine import GetExecutingScriptHash, GetCallingScriptHash, GetEntryScriptHash, GetScriptContainer
from boa.interop.Ontology.Native import Invoke
from boa.interop.Ontology.Runtime import GetCurrentBlockHash
from boa.builtins import ToScriptHash, concat, state
from boa.interop.System.Transaction import GetTransactionHash

# the script hash of this contract
ContractAddress = GetExecutingScriptHash()
ONGAddress = bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02')

Admin = ToScriptHash("XXXX")

INITIALIZED = "Init"
TOTAL_ONG_KEY = "TotalONG"
COMMISSION_KEY = "Commission"

ROUND_PREFIX = "G01"
CURRENT_ROUND_KEY = "G02"
# ROUND_PREFIX + CURRENT_ROUND_KEY + ROUND_STATUS --
ROUND_STATUS = "G03"
# ROUND_PREFIX + CURRENT_ROUND_KEY + DIVIDEND_FOR_BANKERS_PERCENTAGE  -- to store 48
DIVIDEND_FOR_BANKERS_PERCENTAGE = "G04"
# ROUND_PREFIX + CURRENT_ROUND_KEY + RUNNING_VAULT_PERCENTAGE -- to store 50
RUNNING_VAULT_PERCENTAGE = "G05"
# ROUND_PREFIX +  CURRENT_ROUND_KEY + BANKERS_LIST_KEY --
BANKERS_LIST_KEY = "G06"
# ROUND_PREFIX + CURRENT_ROUND_KEY + BANKERS_INVESTMENT_KEY -- total investment --
BANKERS_INVESTMENT_KEY = "G07"
Ejemplo n.º 5
0
from boa.interop.Ontology.Contract import Migrate
from boa.interop.System.Storage import GetContext, Get, Put, Delete
from boa.interop.System.Runtime import CheckWitness, GetTime, Notify, Serialize, Deserialize
from boa.interop.System.ExecutionEngine import GetExecutingScriptHash, GetCallingScriptHash, GetEntryScriptHash, GetScriptContainer
from boa.interop.Ontology.Native import Invoke
from boa.interop.Ontology.Runtime import GetCurrentBlockHash
from boa.builtins import ToScriptHash, concat, state
from boa.interop.System.Transaction import GetTransactionHash

# the script hash of this contract
ContractAddress = GetExecutingScriptHash()
ONGAddress = bytearray(
    b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02'
)

Admin = ToScriptHash("AShumYRy1bWULWq8PqVTLEeNagxwNzA479")

INITIALIZED = "Init"
TOTAL_ONG_KEY = "TotalONG"
COMMISSION_KEY = "Commission"

ROUND_PREFIX = "G01"
CURRENT_ROUND_KEY = "G02"
# ROUND_PREFIX + CURRENT_ROUND_KEY + ROUND_STATUS --
ROUND_STATUS = "G03"
# ROUND_PREFIX + CURRENT_ROUND_KEY + DIVIDEND_FOR_BANKERS_PERCENTAGE  -- to store 48
DIVIDEND_FOR_BANKERS_PERCENTAGE = "G04"
# ROUND_PREFIX + CURRENT_ROUND_KEY + RUNNING_VAULT_PERCENTAGE -- to store 50
RUNNING_VAULT_PERCENTAGE = "G05"
# ROUND_PREFIX +  CURRENT_ROUND_KEY + BANKERS_LIST_KEY --
BANKERS_LIST_KEY = "G06"
Ejemplo n.º 6
0

InitialPrice = 1000000000
PaperHolderPercentage = 50
ReferralAwardPercentage = 1
AwardPercentage = 45

PureAwardExcludeCommissionFee = 98

# the script hash of this contract
ContractAddress = GetExecutingScriptHash()
ONGAddress = bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02')
# Skyinglyh account
# Admin = ToScriptHash('AQf4Mzu1YJrhz9f3aRkkwSm9n3qhXGSh4p')
# LuckyNumber  account
Admin = ToScriptHash('AYqCVffRcbPkf1BVCYPJqqoiFTFmvwYKhG')


# Beijing time 2018-11-15-16:30:00
# each round will last 3 minutes
StartTime = 1542270600
RoundDurationMinutes = 3

def Main(operation, args):
    ######################## for Admin to invoke Begin ###############
    if operation == "init":
        # if len(args) != 0:
        #     return False
        return init()
    if operation == "startNewRound":
        # if len(args) != 0:
Ejemplo n.º 7
0
from boa.interop.Ontology.Runtime import AddressToBase58, Base58ToAddress
from boa.interop.System.Storage import GetContext, Get, Put, Delete
from boa.interop.System.Runtime import Notify, CheckWitness
from boa.interop.System.Action import RegisterAction
from boa.builtins import concat, ToScriptHash

TransferEvent = RegisterAction("transfer", "from", "to", "amount")
ApprovalEvent = RegisterAction("approval", "owner", "spender", "amount")

ctx = GetContext()

NAME = 'DXToken'
SYMBOL = 'DX'
DECIMALS = 10
TOTAL_AMOUNT = 1000000000
OWNER = ToScriptHash("ANH5bHrrt111XwNEnuPZj6u95Dd6u7G4D6")

BALANCE_PREFIX = b'\x01'
APPROVE_PREFIX = b'\x02'

SUPPLY_KEY = 'TotalSupply'

def approve(owner,spender,amount):
    if len(spender) != 20 or len(owner) != 20:
        raise Exception("address length error")
    if CheckWitness(owner) == False:
        return False
    if amount > balanceOf(owner):
        return False
    key = concat(concat(APPROVE_PREFIX,owner),spender)
    Put(ctx, key, amount)
from boa.interop.Ontology.Contract import Migrate
from boa.interop.System.Storage import GetContext, Get, Put, Delete
from boa.interop.System.Runtime import CheckWitness, GetTime, Notify, Serialize, Deserialize
from boa.interop.System.ExecutionEngine import GetExecutingScriptHash, GetCallingScriptHash, GetEntryScriptHash
from boa.interop.Ontology.Native import Invoke
from boa.interop.Ontology.Runtime import GetCurrentBlockHash
from boa.builtins import ToScriptHash, concat, state

ContractAddress = GetExecutingScriptHash()
# ONTAddress = bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01')
# ONGAddress = bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02')

ONTAddress = ToScriptHash("AFmseVrdL9f9oyCzZefL9tG6UbvhUMqNMV")
ONGAddress = ToScriptHash("AFmseVrdL9f9oyCzZefL9tG6UbvhfRZMHJ")


def Main(operation, args):
    if operation == "invest":
        fromAcct = args[0]
        ontAmount = args[1]
        return invest(fromAcct, ontAmount)
    if operation == "withdraw":
        toAcct = args[0]
        ontAmount = args[1]
        return withdraw(toAcct, ontAmount)
    if operation == "checkAllowance":
        account = args[0]
        return checkAllowance(account)
    if operation == "checkWithdraw":
        account = args[0]
        return checkWithdraw(account)
Ejemplo n.º 9
0
from boa.interop.System.Storage import GetContext, Get, Put, Delete
from boa.interop.System.Runtime import Notify, CheckWitness
from boa.interop.System.Action import RegisterAction
from boa.builtins import concat, ToScriptHash
# from boa.interop.Ontology.Runtime import AddressToBase58, Base58ToAddress

TransferEvent = RegisterAction("transfer", "from", "to", "amount")
ApprovalEvent = RegisterAction("approval", "owner", "spender", "amount")

ctx = GetContext()

NAME = 'MyToken'
SYMBOL = 'MYT'
DECIMALS = 8
FACTOR = 100000000
OWNER = ToScriptHash("ASSxYHNSsh4FdF2iNvHdh3Np2sgWU21hfp")
# OWNER = bytearray(b'\x61\x6f\x2a\x4a\x38\x39\x6f\xf2\x03\xea\x01\xe6\xc0\x70\xae\x42\x1b\xb8\xce\x2d')
TOTAL_AMOUNT = 1000000000
BALANCE_PREFIX = bytearray(b'\x01')
APPROVE_PREFIX = b'\x02'
SUPPLY_KEY = 'TotalSupply'


def Main(operation, args):
    """
    :param operation:
    :param args:
    :return:
    """
    # 'init' has to be invokded first after deploying the contract to store the necessary and important info in the blockchain
    if operation == 'init':
Ejemplo n.º 10
0
def Div(a, b):
    """
    Integer division of two numbers, truncating the quotient.
    """
    Require(b > 0)
    c = a / b
    return c


TransferEvent = RegisterAction("transfer", "fromAcct", "toAcct", "tokenId",
                               "amount")
ApprovalEvent = RegisterAction("approval", "owner", "spender", "tokenId",
                               "amount")

# modify to the admin address
admin = ToScriptHash('XXXX')

# TOKEN_ID1 is used to identify different tokens, to help store the token name, token symbol and balance
TOKEN_ID_LIST = [b'\x01', b'\x02', b'\x03', b'\x04', b'\x05']

# TOKEN_ID + NAME --- to store the name of the TOKEN_ID token
NAME = 'Name'
# TOKEN_ID + SYMBOL --- to store the symbol of the TOKEN_ID token
SYMBOL = 'Symbol'
# TOKEN_ID+ BALANCE + address --- to store the balance of address in terms of the TOKEN_ID token
BALANCE = 'Balance'
# TOKEN_ID + TOTAL_SUPPLY  --- to store the total supply of the TOKEN_ID token
TOTAL_SUPPLY = 'TotalSupply'
# TOKEN_ID + APPROVE + owner + spender -- to store the approved TOKEN_ID amount to the spender by the owner
APPROVE = 'Approve'
# INITED --- to store "TRUE" in order to make sure this contract can only be deployed once
Ejemplo n.º 11
0
symbol_ = "P3D"

decimal_ = 8
dividendFee_ = 10
referralFee_ = 33
# 0.01 ONG
tokenPriceInitial_ = 10000000
tokenPriceIncremental_ = 10000000
# Ong decimal is 9
ongMagnitude_ = Pwr(10, 9)
tokenMagnitude_ = Pwr(10, decimal_)
# proof of stake (defaults at 100 P3D tokens)
statingRequirement_ = Mul(100, tokenMagnitude_)

# ongContractAddress_ = bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02')
ONGContractAddress_ = ToScriptHash("AFmseVrdL9f9oyCzZefL9tG6UbvhfRZMHJ")
selfContractAddr_ = GetExecutingScriptHash()
admin_ = ToScriptHash("AQf4Mzu1YJrhz9f3aRkkwSm9n3qhXGSh4p")


ADMIN_SUFFIX = "admin"
MANAGER_SUFFIX = "manager"
CUSTOMER_SUFFIX = "customer"
TOKENBALANCE_SUFFIX = bytearray(b'\x01')
DIVIDEND_SUFFIX = bytearray(b'\x02')
REFERRALBALANCE_SUFFIX = bytearray(b'\x03')
PAIDEARNINGS_SUFFIX = bytearray(b'\0x04')

ANTI_EARLY_WHALE_KEY = "anti_early_whale"
TOTAL_SUPPLY_KEY = "P3D_total_supply"
PRICE_PER_TOKEN_KEY = "price_per_token"
Ejemplo n.º 12
0
"""
An Example of OEP-4
"""
from boa.interop.System.Storage import GetContext, Get, Put, Delete
from boa.interop.System.Runtime import Notify, CheckWitness
from boa.builtins import concat, ToScriptHash
ctx = GetContext()

NAME = 'X-Token'
SYMBOL = 'XToken'
DECIMAL = 8
FACTOR = 100000000
OWNER = ToScriptHash("ASYkgyWm4GFiXqVKZs6XrjaN3HnFVGRhDs")
TOTAL_AMOUNT = 1000000000
TRANSFER_PREFIX = bytearray(b'\x01')
APPROVE_PREFIX = bytearray(b'\x02 ')

SUPPLY_KEY = 'totoalSupply'


def Main(operation, args):
    """
    :param operation:
    :param args:
    :return:
    """
    if operation == 'name':
        return name()
    if operation == 'totalSupply':
        return totalSupply()
    if operation == 'init':
Ejemplo n.º 13
0
tokenSupply_ = 0
decimal = 8
dividendFee_ = 10
referralFee_ = 3
# 0.01 ONG
tokenPriceInitial_ = 10000000
tokenPriceIncremental_ = 10000000
# Ong decimal is 9
magnitude = Pwr(10, 9)

# proof of stake (defaults at 100 P3D tokens)
statingRequirement_ = Mul(100, magnitude)

ongContractAddress_ = bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02')
selfAddr_ = GetExecutingScriptHash()
initial_admin_ = ToScriptHash("AQf4Mzu1YJrhz9f3aRkkwSm9n3qhXGSh4p")
ADMIN_PREFIX = "admin"
noneAdmin_ = True
TOKENBALANCE_PREFIX = bytearray(b'\x01')
DIVIDENDS_PREFIX = bytearray(b'\x02')
REFERRALBALANCE_PREFIX = bytearray(b'\x03')
PAYOUTSTO_PREFIX = bytearray(b'\0x04')

profitPerShare_ = 0


def main():
    a = 3
    b = 4
    c = Pwr(a, b)
    return c
Ejemplo n.º 14
0
from boa.interop.System.Action import RegisterAction
from boa.interop.System.Runtime import Notify, CheckWitness
from boa.interop.System.Storage import GetContext, Get, Put, Delete

# from boa.interop.Ontology.Runtime import AddressToBase58, Base58ToAddress

TransferEvent = RegisterAction("transfer", "from", "to", "amount")
ApprovalEvent = RegisterAction("approval", "owner", "spender", "amount")

ctx = GetContext()

NAME = 'Reputation'
SYMBOL = 'REP'
DECIMALS = 8
FACTOR = 100000000
OWNER = ToScriptHash("ANXE3XovCwBH1ckQnPc6vKYiTwRXyrVToD")
# OWNER = bytearray(b'\x61\x6f\x2a\x4a\x38\x39\x6f\xf2\x03\xea\x01\xe6\xc0\x70\xae\x42\x1b\xb8\xce\x2d')
TOTAL_AMOUNT = 1000000000
BALANCE_PREFIX = bytearray(b'\x01')
APPROVE_PREFIX = b'\x02'
SUPPLY_KEY = 'TotalSupply'


def Main(operation, args):
    """
    :param operation:
    :param args:
    :return:
    """
    # 'init' has to be invokded first after deploying the contract to store the necessary and important info in the blockchain
    if operation == 'init':
Ejemplo n.º 15
0
from boa.interop.System.Storage import GetContext, Get, Put, Delete
from boa.interop.System.Runtime import CheckWitness, GetTime, Notify, Serialize, Deserialize, Log
from boa.interop.System.Action import RegisterAction
from boa.builtins import concat, ToScriptHash, range, state
from boa.interop.System.App import RegisterAppCall
from boa.interop.Ontology.Native import Invoke
from boa.interop.System.ExecutionEngine import GetExecutingScriptHash, GetScriptContainer
from boa.interop.System.Transaction import GetTransactionHash

BetEvent = RegisterAction("placebet", "address", "gameid", "horv", "amount")

oracleContract = RegisterAppCall('ca5744eadc5234b8d712560641ffa08d0ec63bf8',
                                 'operation', 'args')
ctx = GetContext()
selfAddr = GetExecutingScriptHash()
adminAddress = ToScriptHash("Ad4pjz2bqep4RhQrUAzMuZJkBC3qJ1tZuT")
operaterAddress = ToScriptHash("AS3SCXw8GKTEeXpdwVw7EcC4rqSebFYpfb")

# 5% fee cost
FeeRate = 5
Name = "NBA Guess"
#keys
GameCountPrefix = 'GameCount'
GamePrefix = 'Game'
BetPrefix = 'Bet'
OraclePrefix = 'Oracle'
OracleResPrefix = 'OracleRes'
AccountPrefix = 'Account'
EndPrefix = 'EndBet'
FeePoolPrefix = 'FeePool'
Ejemplo n.º 16
0
def deploy():
    """
    can only be deployed once
    :return:
    """
    deployed = Get(GetContext(), DEPLOYED_KEY)

    if deployed != _POSITIVE_:

        # only admin can deploy the contract
        nouse = Require(CheckWitness(admin_))

        # Set admin
        admin_key = concatKey(admin_, ADMIN_SUFFIX)
        Put(GetContext(), admin_key, _POSITIVE_)

        # Set Avalanche Team address

        # Set managers (set as both admin and manager)
        manager1 = ToScriptHash("AQf4Mzu1YJrhz9f3aRkkwSm9n3qhXGSh4p")
        key = concatKey(manager1, MANAGER_SUFFIX)
        Put(GetContext(), key, _POSITIVE_)

        manager2 = ToScriptHash("ASUwFccvYFrrWR6vsZhhNszLFNvCLA5qS6")
        key = concatKey(manager2, MANAGER_SUFFIX)
        Put(GetContext(), key, _POSITIVE_)
        #  can add manager2, 3, 4, 5, 6

        # set name info
        Put(GetContext(), NAME_KEY, initial_name)
        # set symbol info
        Put(GetContext(), SYMBOL_KEY, initial_symbol)
        # set decimal info, decimal_ cannot be changed
        Put(GetContext(), DECIMAL_KEY, decimal_)

        # set Fee info


        # set anti early whale key as true for the early stage
        Put(GetContext(), ANTI_EARLY_WHALE_KEY, _POSITIVE_)
        # initiate totalSupply
        Put(GetContext(), TOTAL_SUPPLY_KEY, 0)
        # initiate fakeTotalSupply
        Put(GetContext(), FAKE_TOTAL_SUPPLY_FOR_HOLDER_DIVIDENDS_KEY, 0)
        # initiate total ONG Balance
        Put(GetContext(), TOTAL_ONG_KEY, 0)

        # initiate initialTokenPrice_ and initialTokenPriceIncremental_
        Put(GetContext(), INITIAL_TOKEN_PRICE, initialTokenPrice_)
        Put(GetContext(), INITIAL_TOKEN_PRICE_INCREMENTAL, initialTokenPriceIncremental_)
        # initiate pricePerToken
        _actualInitialTokenPrice = Sub(initialTokenPrice_, initialTokenPriceIncremental_)
        Put(GetContext(), PRICE_PER_TOKEN_KEY, _actualInitialTokenPrice)
        # initiate profit per token
        Put(GetContext(), PROFIT_PER_TOKEN_KEY, 0)
        # initial team_ info
        Put(GetContext(), concatKey(team_, REFERRAL_BALANCE_SUFFIX), 0)
        # initiate referral requirement
        Put(GetContext(), REFERRAL_STAKE_REQUIREMENT_KEY, referralStakeRequirement_)

        # save the ratio for the convenience of usage
        Put(GetContext(), QUANTITY_INCREASE_PER_PRICE_KEY, Div(tokenMagnitude_, initialTokenPriceIncremental_))

        # Mark the contract has been deployed
        Put(GetContext(), DEPLOYED_KEY, _POSITIVE_)

        Notify(["congrats, admin, you have deployed the contract successfuly"])
    else:
        Notify(["Idiot admin, the contract has already been deployed."])
        return False
    return True
Ejemplo n.º 17
0
from boa.interop.System.Storage import GetContext, Get, Put, Delete
from boa.interop.System.Runtime import Notify, CheckWitness
from boa.builtins import concat, ToScriptHash

ctx = GetContext()

NAME = 'tokenName'
SYMBOL = 'Symbol'
DECIMAL = 8
FACTOR = 100000000
OWNER = ToScriptHash("AUQ2cqRs2daQBqTFs6Zun8eYXRe4a9JZUC")
TOTAL_AMOUNT = 1000000000

TRANSFER_PREFIX = bytearray(b'\x01')
APPROVE_PREFIX = bytearray(b'\x02 ')

SUPPLY_KEY = 'totoalSupply'


def Main(operation, args):
    if operation == 'Name':
        return Name()
    if operation == 'TotalSupply':
        return TotalSupply()
    if operation == 'Init':
        return Init()
    if operation == 'Symbol':
        return Symbol()
    if operation == 'Transfer':
        if len(args) != 3:
            return False
Ejemplo n.º 18
0
from boa.interop.Ontology.Native import Invoke
from boa.builtins import ToScriptHash, state
from boa.interop.System.Runtime import Notify

# ONT Big endian Script Hash: 0x0100000000000000000000000000000000000000
OntContract = ToScriptHash("AFmseVrdL9f9oyCzZefL9tG6UbvhUMqNMV")
# ONG Big endian Script Hash: 0x0200000000000000000000000000000000000000
OngContract = ToScriptHash("AFmseVrdL9f9oyCzZefL9tG6UbvhfRZMHJ")


def Main(operation, args):
    if operation == "transferOntOng":
        return TransferOntOng()


def TransferOntOng(from_acct, to_acct, ont, ong):
    param = state(from_acct, to_acct, ont)
    res = Invoke(0, OntContract, "transfer", [param])
    if res != b'\x01':
        Notify("transferONT succeed")
        raise Exception("tansfer ont error.")
    param = state(from_acct, to_acct, ong)
    ret = Invoke(0, OngContract, "transfer", [param])
    if ret != b'\x01':
        Notify("transferONG succeed")
        raise Exception("tansfer ong error.")
    return True
Ejemplo n.º 19
0
"""
An Example of OEP-4
"""
from boa.interop.System.Storage import GetContext, Get, Put, Delete
from boa.interop.System.Runtime import Notify, CheckWitness
from boa.builtins import concat, ToScriptHash
from boa.interop.Ontology.Runtime import AddressToBase58
ctx = GetContext()

NAME = 'MyToken'
SYMBOL = 'MYT'
DECIMALS = 8
FACTOR = 100000000
OWNER = ToScriptHash("AQf4Mzu1YJrhz9f3aRkkwSm9n3qhXGSh4p")
# OWNER = bytearray(b'\x61\x6f\x2a\x4a\x38\x39\x6f\xf2\x03\xea\x01\xe6\xc0\x70\xae\x42\x1b\xb8\xce\x2d')
TOTAL_AMOUNT = 1000000000
BALANCE_PREFIX = bytearray(b'\x01')
APPROVE_PREFIX = b'\x02'

SUPPLY_KEY = 'totalSupply'


def Main(operation, args):
    """
    :param operation:
    :param args:
    :return:
    """
    # 'init' has to be invokded first after deploying the contract to store the necessary and important info in the blockchain
    if operation == 'init':
        return init()
Ejemplo n.º 20
0
    :param a:
    :return: sqrt(a)
    """
    c = Div(Add(a, 1), 2)
    b = a
    while (c < b):
        b = c
        c = Div(Add(Div(a, c), c), 2)
    return c


ONGAddress = bytearray(
    b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02'
)
# the original company
Dev1 = ToScriptHash("AYqCVffRcbPkf1BVCYPJqqoiFTFmvwYKhG")
# the cooperator
Dev2 = ToScriptHash("ANTPeXCffDZCaCXxY9u2UdssB2EYpP4BMh")

Operater = ToScriptHash("AQf4Mzu1YJrhz9f3aRkkwSm9n3qhXGSh4p")

INIT_KEY = "Inited"
ContractAddress = GetExecutingScriptHash()
ONGMagnitude = 1000000000
Magnitude = 1000000000000000000000000000000

OracleContract = RegisterAppCall('e0d635c7eb2c5eaa7d2207756a4c03a89790934a',
                                 'operation', 'args')
SelfContractAddress = GetExecutingScriptHash()

DEV_PROFIT_PREFIX = "DEV"
Ejemplo n.º 21
0
"""
An Example of OEP-4
"""
from boa.interop.System.Storage import GetContext, Get, Put, Delete
from boa.interop.System.Runtime import Notify, CheckWitness
from boa.builtins import concat, ToScriptHash
ctx = GetContext()

NAME = 'MyToken'
SYMBOL = 'MYT'
DECIMALS = 8
FACTOR = 100000000
OWNER = ToScriptHash("AazEvfQPcQ2GEFFPLF1ZLwQ7K5jDn81hve")
# OWNER = bytearray(b'\x61\x6f\x2a\x4a\x38\x39\x6f\xf2\x03\xea\x01\xe6\xc0\x70\xae\x42\x1b\xb8\xce\x2d')
TOTAL_AMOUNT = 1000000000
BALANCE_PREFIX = bytearray(b'\x01')
APPROVE_PREFIX = bytearray(b'\x02')

SUPPLY_KEY = 'totalSupply'


def Main(operation, args):
    """
    :param operation:
    :param args:
    :return:
    """
    # 'init' has to be invokded first after deploying the contract to store the necessary and important info in the blockchain
    if operation == 'init':
        return init()
    if operation == 'name':
Ejemplo n.º 22
0
from boa.interop.Ontology.Runtime import GetCurrentBlockHash
from boa.interop.System.Runtime import GetTime, Notify, Serialize, Deserialize
from boa.interop.System.Storage import Get, Put, Delete, GetContext
from boa.builtins import concat, ToScriptHash

PROB_MAP = 'prob_map'
OWNER = ToScriptHash('AcTamnvFVZmR3ykoAbz291w2t1T33GtnY6')
PROB_MAP_RAW = 'prob_map_raw'


def Main(operation, args):
    if operation == 'roll_gacha':
        return roll_gacha()
    elif operation == 'add_storage':
        if len(args) != 2:
            return False
        return add_storage(args[0], args[1])
    elif operation == 'add_card':
        if len(args) != 1:
            return False
        return
    elif operation == 'get_storage':
        if len(args) != 1:
            return False
        return get_storage(args[0])
    elif operation == 'init':
        return init()
    elif operation == 'get_prob':
        return get_prob()
    elif operation == 'has_key':
        return has_key()
from boa.interop.System.Storage import GetContext, Get, Put, Delete
from boa.interop.Ontology.Native import Invoke
from boa.builtins import ToScriptHash, state
from boa.interop.System.Runtime import Notify
from boa.interop.System.ExecutionEngine import GetExecutingScriptHash


# ONT Big endian Script Hash: 0x0100000000000000000000000000000000000000
OntContract = ToScriptHash("AFmseVrdL9f9oyCzZefL9tG6UbvhUMqNMV")
# ONG Big endian Script Hash: 0x0200000000000000000000000000000000000000
OngContract = ToScriptHash("AFmseVrdL9f9oyCzZefL9tG6UbvhfRZMHJ")
OWNER = ToScriptHash("AFrVXcA9o9G3vQnwaEPyGf6ysd82X76gRv")
SUPPLY_KEY = 'TotalSupply'
ctx = GetContext()
ALL_USER = "******"
HISTORY = "HISTORY"
INITIAL_PRICE = "InitPrice"

selfContractAddress = GetExecutingScriptHash()


def Main(operation, args):
    if operation == "getPrice":
        userid = args[0]
        return getPrice(userid)
    if operation == "getAmount":
        userid = args[0]
        return getAmount(userid)
    if operation == "transferOntOng":
        if len(args) == 4:
            fromAcct = args[0]
Ejemplo n.º 24
0
from boa.interop.Ontology.Runtime import Base58ToAddress
from boa.interop.Ontology.Native import Invoke

# storage keys
DEALER_KEY = 'dealer:'
DEALER_ROOMS_KEY = "dealer_rooms_all:"
ROOMS_KEY = "rooms_map:"
ALL_ROOMS_KEY = "all_rooms"
DEALER_DEPOSITE_MAP = "dealer_deposite_key:"
MAX_GAME_ID = "max_game_id"

# DECIMAL_FACTOR for ong
DECIMAL_FACTOR = 1000000000

# GAME Contract Address
ChinciroDiceContractAddrSH = ToScriptHash(
    '94407f241862c0e57ba6199f6cad09f03f951590')
ChinciroDiceContract = RegisterAppCall(
    '94407f241862c0e57ba6199f6cad09f03f951590', 'operation', 'args')

## THIS CONTRACT ADDRESS
selfContractAddress = GetExecutingScriptHash()

# NATIVE Contract
OngContractAddress = ToScriptHash("AFmseVrdL9f9oyCzZefL9tG6UbvhfRZMHJ")


def Main(operation, args):
    if operation == 'RegisterAsDealer':
        addr = args[0]
        return RegisterAsDealer(addr)
    if operation == 'returnFormatStr':
Ejemplo n.º 25
0
PriceIncremental = 9260
PaperHolderPercentage = 50
ReferralAwardPercentage = 1
AwardPercentage = 35
NextPercentage = 10

WinnerFeeLarge = 10
WinnerFeeSmall = 5

# the script hash of this contract
ContractAddress = GetExecutingScriptHash()
ONGAddress = bytearray(
    b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02'
)
# Skyinglyh account
Admin = ToScriptHash('AQf4Mzu1YJrhz9f3aRkkwSm9n3qhXGSh4p')
# LuckyNumber  account
# Admin = ToScriptHash('AYqCVffRcbPkf1BVCYPJqqoiFTFmvwYKhG')

# PurchaseEvent = RegisterAction("buy", "account", "ongAmount", "paperAmount")

# Beijing time 2018-11-2-16:30:01
# each round will last 30 minutes
StartTime = 1541147410


def Main(operation, args):
    ######################## for Admin to invoke Begin ###############
    if operation == "init":
        # if len(args) != 0:
        #     return False
Ejemplo n.º 26
0
from boa.builtins import sha256
from boa.interop.System.ExecutionEngine import GetScriptContainer, GetCallingScriptHash, GetEntryScriptHash, \
    GetExecutingScriptHash
from boa.interop.System.Transaction import GetTransactionHash
from boa.interop.System.Blockchain import GetHeight
from boa.interop.System.Runtime import GetTime, Serialize, Notify, CheckWitness
from boa.interop.Ontology.Runtime import GetCurrentBlockHash
from boa.interop.System.App import RegisterAppCall
from boa.interop.System.Storage import GetContext, Get, Put,Delete
from boa.builtins import ToScriptHash, state, concat
from boa.interop.Ontology.Native import Invoke

OntContract = ToScriptHash("AFmseVrdL9f9oyCzZefL9tG6UbvhUMqNMV")
# ONG Big endian Script Hash: 0x0200000000000000000000000000000000000000
OngContract = ToScriptHash("AFmseVrdL9f9oyCzZefL9tG6UbvhfRZMHJ")

superadmin = ToScriptHash("AQyjYLQNRXtjr6cPoru1vpCTwehg6EQPCs")

teamaddress = ToScriptHash("AQyjYLQNRXtjr6cPoru1vpCTwehg6EQPCs")

testaddress = ToScriptHash("AHdVYY3oCPho1JmwYYmaPYUTXLsZXMAYL3")

ctx = GetContext()
FEE = 2


BALANCE_PREFIX = bytearray(b'\x01')
GUESS_PREFIX = bytearray(b'\x02')
BET_ID_PREFIX = bytearray(b'\x03')

FACTOR = 100000000