Exemple #1
0
TOTAL_SUPPLY_KEY = 'supply'
OWNER_KEY = 'owner'
BALANCE_KEY = 'balance'
APPROVE_KEY = 'approve'

CONTRACT_HASH = "contracthash"
REDEEM_SCRIPT_KEY = "redeem"
MINLIMIT_KEY = "limit"

BTC_ChainId = 1
ETH_ChainId = 2
ONT_ChainId = 3


Owner = Base58ToAddress('AdzZ2VKufdJWeB8t9a8biXoHbbMe2kZeyH')

# Event
TransferEvent = RegisterAction("transfer", "from", "to", "amount")
ApproveEvent = RegisterAction("approve", "owner", "spender", "amount")
UnlockEvent = RegisterAction("unlock", "toAssetHash", "toAddress", "amount")
LockEvent = RegisterAction("lock", "fromAssetHash", "toChainId", "toAssetHash", "fromAddress", "toAddress", "amount")
SetMinBackBTCEvent = RegisterAction("SetMinBackBTCEvent", "minimumCrossChainTransferLimit")

def Main(operation, args):
    if operation == "init":
        assert(len(args) == 2)
        redeemScript = args[0]
        scriptHash = args[1]
        return init(redeemScript, scriptHash)
Exemple #2
0
from ontology.interop.System.Action import RegisterAction
from ontology.builtins import concat
from ontology.interop.Ontology.Runtime import Base58ToAddress

TransferEvent = RegisterAction("transfer", "from", "to", "amount")
ApprovalEvent = RegisterAction("approval", "owner", "spender", "amount")
TransferOwnershipEvent = RegisterAction("transferOwnership", "oldOwner",
                                        "newOwner")

ctx = GetContext()

NAME = 'pETH'
SYMBOL = 'pETH'
DECIMALS = 18
FACTOR = 1000000000000000000
Operator = Base58ToAddress("ANXE3XovCwBH1ckQnPc6vKYiTwRXyrVToD")
ZERO_ADDRESS = bytearray(
    b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
)
CROSS_CHAIN_CONTRACT_ADDRESS = bytearray(
    b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x09'
)
BALANCE_PREFIX = bytearray(b'\x01')
APPROVE_PREFIX = bytearray(b'\x02')
SUPPLY_KEY = 'TotalSupply'

PROXY_HASH_KEY = "Proxy"

OWNER_KEY = "Owner"

Exemple #3
0
from ontology.interop.System.Storage import GetContext, Get, Put, Delete
from ontology.interop.System.Runtime import Notify, CheckWitness
from ontology.interop.System.Action import RegisterAction
from ontology.builtins import concat
from ontology.interop.Ontology.Runtime import Base58ToAddress

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

ctx = GetContext()

NAME = 'ALLIVE'
SYMBOL = 'ALV'
DECIMALS = 8
FACTOR = 100000000
OWNER = Base58ToAddress("AKmB1QAgcTRyGifWJHsLcP9bERkx5g8Z6P")
TOTAL_AMOUNT = 6000000000
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()
Exemple #4
0
"""

from ontology.builtins import concat, state
from ontology.interop.Ontology.Native import Invoke
from ontology.interop.Ontology.Contract import Migrate
from ontology.interop.Ontology.Runtime import Base58ToAddress
from ontology.interop.System.Runtime import CheckWitness, Notify, Serialize, Deserialize
from ontology.interop.System.ExecutionEngine import GetExecutingScriptHash
from ontology.interop.System.Storage import GetContext, Put, Get, Delete

ZERO_ADDRESS = bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
ONT_ADDRESS = bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01')
ONG_ADDRESS = bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02')

# TODO(fukun): modify admin address
ADMIN = Base58ToAddress("AGoC1LptN4uRFrymW7p7Tu3dFR7Yq2RB2P")
CONTRACT_ADDRESS = GetExecutingScriptHash()
ctx = GetContext()


KEY_OWNER = "k1"
KEY_ONT = "k2_"
KEY_BUCKET = "k3_"
VERSION = 0
INVOKE_SUCCESS = b'\x01'


def Main(op, args):
    if op == "init":
        return init()
Exemple #5
0
ctx = GetContext()
CONTRACT_ADDRESS = GetExecutingScriptHash()
CROSS_CHAIN_CONTRACT_ADDRESS = bytearray(
    b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x09'
)

NAME = 'MyToken2'
SYMBOL = 'MYT2'
DECIMALS = 8
FACTOR = 100000000
TOTAL_AMOUNT = 1000000000
BALANCE_PREFIX = bytearray(b'\x01')
APPROVE_PREFIX = b'\x02'
SUPPLY_KEY = 'TotalSupply'
DESTINATION_CONTRACT = "Destination_contract"
OWNER = Base58ToAddress("AMNuzSEyUW4PAddpNS14zZSvrVGYhzyf5D")


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':
        return name()
    if operation == 'symbol':
        return symbol()
OntCversion = '2.0.0'
from ontology.builtins import concat, sha256
from ontology.interop.Ontology.Runtime import Base58ToAddress
from ontology.interop.System.Action import RegisterAction
from ontology.interop.System.App import DynamicAppCall
from ontology.interop.System.ExecutionEngine import GetExecutingScriptHash, GetCallingScriptHash
from ontology.interop.System.Runtime import CheckWitness, GetTime, Notify, Serialize
from ontology.interop.System.Storage import GetContext, Get, Put, Delete
from ontology.libont import bytearray_reverse

EXPIRY_TIME = 30

INITIALIZED = "INIT"
MINIMUM_CONSUMER_GAS_LIMIT = 100000000
OWNER = Base58ToAddress("AGcWFujmhcya3Zi31qdYsckyAUWpoRktUa")
LINKTOKEN_ADDRESS = 'linktokenAddress'
COMMITMENTS_PRIFX = 'commitments'
AUTHORIZE_NODES_PREFIX = 'authorizeNodes'
WITHDRAWABLETOKENS = 'withdrawableTokens'

ContractAddress = GetExecutingScriptHash()

CancelOracleRequestEvent = RegisterAction("cancelOracleRequest", "requestId")

OracleRequestEvent = RegisterAction("oracleRequest", "specId", "sender",
                                    "requestId", "payment", "callbackAddress",
                                    "callbackFunctionId", "expiration",
                                    "dataVersion", "data", "callFunctionId")


def Main(operation, args):
Exemple #7
0
"""
TexasHoldem Game
"""
from ontology.interop.Ontology.Contract import Migrate
from ontology.interop.System.Storage import GetContext, Get, Put
from ontology.interop.System.Runtime import CheckWitness, GetTime, Notify
from ontology.interop.Ontology.Runtime import GetCurrentBlockHash, Base58ToAddress
from ontology.builtins import concat, sha256

Admin = Base58ToAddress('ANTPeXCffDZCaCXxY9u2UdssB2EYpP4BMh')
PLAYER_LAST_CHECK_IN_DAY = "P1"
GAME_SALT_KEY = "G1"
DaySeconds = 86400


def Main(operation, args):
    ######################### for Admin to invoke Begin #########################
    if operation == "startGame":
        assert (len(args) == 3)
        pokerHashList = args[0]
        playerList = args[1]
        gameId = args[2]
        return startGame(pokerHashList, playerList, gameId)
    if operation == "endGame":
        assert (len(args) == 2)
        gameId = args[0]
        salt = args[1]
        return endGame(gameId, salt)
    if operation == "migrateContract":
        assert (len(args) == 7)
        code = args[0]
from ontology.interop.System.Storage import GetContext, Get, Put, Delete
from ontology.interop.System.Runtime import CheckWitness, GetTime, Notify, Serialize, Log, Deserialize
from ontology.interop.System.ExecutionEngine import GetExecutingScriptHash
from ontology.interop.Ontology.Native import Invoke
from ontology.builtins import *
from ontology.interop.Ontology.Runtime import Base58ToAddress

adminAddress = Base58ToAddress("AY5ZBb7qtjdnp3ChweqMqcXdavCJVqXj7F")
ctx = GetContext()
selfAddr = GetExecutingScriptHash()
INITED = 'Initialized'
CUT = 'cut'
LAST_GEN0_SALE_PRICE = 'lastGen0SalePrices'
TOKEN_ID_TO_AUCTION_PREFIX = 'tokenIdToAuction'
GEN0_SALE_COUNT = 'gen0SaleCount'
CFO = 'cfo'
DRAGONADDRESS = 'dragonAddress'
VERSION = '0.0.2'


def Main(operation, args):
    if operation == 'init':
        if len(args) != 2:
            return False
        _caller = args[0]
        _cut = args[1]
        # There return False ,But The operation on the Storage has taken effect
        VaasAssert(not init(_caller, _cut) and Get(ctx, INITED) !=
                   "TRUE")  #Hope that the initialization is not effective.
        return True
    if operation == 'createAuction':
Exemple #9
0
def create_bet(address, amount_staked, stock_ticker, sign, margin, date, init_price):
    byte_address = Base58ToAddress(address)
    assert (CheckWitness(byte_address))

    if len(byte_address) != 20:
        Notify(['Invalid address'])
        return False

    # check if user list exists
    user_info = Get(ctx, USERKEY)
    if user_info:
        all_users = Deserialize(user_info)
    else:
        Notify(['User list is empty'])
        return False

    # check if user exists
    if address not in all_users:
        Notify(['User not created'])
        return False

    # if user exists, bank map exists. check bank condition
    bank_info = Get(ctx, BANKEY)
    bank_map = Deserialize(bank_info)

    if bank_map[address] < amount_staked:
        Notify(['Insufficient funds'])
        return False

    # something to check stock stock_ticker

    if sign != 1 and sign != -1:
        Notify(['Invalid sign'])
        return False

    # something to check if the time is valid and not in the past

    else:
        # after all conditions have passed, get the rep map.
        rep_info = Get(ctx, REPKEY)
        rep_map = Deserialize(rep_info)

        # init data structures
        for_map = {}
        # against_map = {} don't need to store empty map
        for_list = []
        against_list = []
        for_rep = rep_map[address]
        against_rep = 0
        for_staked = 0
        against_staked = 0
        for_count = 1
        against_count = 0
        for_avg_rep = rep_map[address]
        against_avg_rep = 0
        prob = FACTOR * 100
        Notify(['Data structures successfully inited'])

        # update data
        target_price = init_price + init_price * sign * margin / 100
        for_map[address] = amount_staked
        for_list.append(address)
        for_staked += amount_staked
        Notify(['Data structures successfully updated'])

        # FR, AR, FS, AS, FC, AC, UD, MA, TP, SE are in val_list
        val_list = []

        # populate val_list with relevant values
        val_list.append(for_rep)
        val_list.append(against_rep)
        val_list.append(for_staked)
        val_list.append(against_staked)
        val_list.append(for_count)
        val_list.append(against_count)
        val_list.append(sign)
        val_list.append(margin)
        val_list.append(target_price)
        val_list.append(date)
        val_list.append(stock_ticker)
        val_list.append(for_avg_rep)
        val_list.append(against_avg_rep)
        val_list.append(prob)
        
        Notify(['val_list successfully populated'])

        # prepare data structures for storage
        fm_info = Serialize(for_map)
        # am_info = Serialize(against_map) don't need to store empty map
        fl_info = Serialize(for_list)
        val_info = Serialize(val_list)

        # get current bet number to create bet specific keys for relevant data
        bet = Get(ctx, BETKEY)

        # put data structures onchain
        Put(ctx, concatkey(bet, FM_PREFIX), fm_info)
        # Put(ctx, concatkey(bet, AM_PREFIX), am_info)
        Put(ctx, concatkey(bet, FL_PREFIX), fl_info)
        Put(ctx, concatkey(bet, VAL_PREFIX), val_info)
        Notify(['Data structures stored onchain'])

        # check if ab_info is populated/exists
        ab_info = Get(ctx, ABKEY)
        if ab_info:
            active_bets = Deserialize(ab_info)
        else:
            active_bets = []

        # update active bet list and put back onchain
        active_bets.append(bet)
        ab_info = Serialize(active_bets)
        Put(ctx, ABKEY, ab_info)
        Notify(['Active bets updated', bet])

        # add bet to list of bets the user has participated in
        bl_info = Get(ctx, concatkey(address, BL_PREFIX))
        if bl_info:
            bet_list = Deserialize(bl_info)
        else:
            bet_list = []

        bet_list.append(bet)
        bl_info = Serialize(bet_list)
        Put(ctx, concatkey(address, BL_PREFIX), bl_info)

        Notify(['User bet list updated'])

        # update winners' track record
        record_info = Get(ctx, concatkey(address, RC_PREFIX))
        if record_info:
            record_map = Deserialize(record_info)
        else:
            record_map = {}
            
        # 1 means bet in progress
        record_map[concatkey(bet, BT_PREFIX)] = 1 
        record_info = Serialize(record_map)
        Put(ctx, concatkey(address, RC_PREFIX), record_info)
        Notify(['User track record updated'])
        
        profit_info = Get(ctx, concatkey(address, PT_PREFIX))
        if profit_info:
            profit_map = Deserialize(profit_info)
        else:
            profit_map = {}
        
        # 0 profit so far for this bet because the bet is still ongoing
        profit_map[concatkey(bet, BT_PREFIX)] = 0
        profit_info = Serialize(profit_map)
        Put(ctx, concatkey(address, PT_PREFIX), profit_info)
        Notify(['User profit per bet updated'])

        # update current bet number and put back onchain
        new_bet = bet + 1
        Put(ctx, BETKEY, new_bet)

        # update bet creator's public bank ledger and actual wallet
        bank_map[address] -= amount_staked
        bank_info = Serialize(bank_map)
        Put(ctx, BANKEY, bank_info)
        Notify(['bank_map updated'])

        subtract_bank(address, amount_staked)
        Notify(['user wallet updated'])

        # timing: voting period, observation period, payout.
        # result checking func handled by oracle
        # for testing only: use payout on specific bet, manually remember bet IDs
        # figure out how to automate payout as soon as bet is created.
        Notify(['bet', bet, val_list])
        return True
Exemple #10
0
def vote(bet, address, amount_staked, for_against):
    byte_address = Base58ToAddress(address)
    assert (CheckWitness(byte_address))

    # check if active bet list is populated/exists
    ab_info = Get(ctx, ABKEY)
    if ab_info:
        active_bets = Deserialize(ab_info)
    else:
        Notify(['There are no active bets'])
        return False

    # check if bet argument is an active bet
    if bet not in active_bets:
        Notify(['Bet is not active'])
        return False

    # check if user list exists
    user_info = Get(ctx, USERKEY)
    if user_info:
        all_users = Deserialize(user_info)
    else:
        Notify(['User list is empty'])
        return False

    # check if user has been created
    if address not in all_users:
        Notify(['User not created'])
        return False

    # check if address is valid
    if len(byte_address) != 20:
        Notify(['Invalid address'])
        return False

    # check if bank is sufficient for staking
    bank_info = Get(ctx, BANKEY)
    bank_map = Deserialize(bank_info)
    
    # add bet to list of bets the user has participated in
    bl_info = Get(ctx, concatkey(address, BL_PREFIX))
    if bl_info:
        bet_list = Deserialize(bl_info)
        if bet in bet_list:
            Notify(['User already voted on this bet'])
            return False
    else:
        bet_list = []

    if bank_map[address] < amount_staked:
        Notify(['Insufficient funds'])
        return False
        

    else:
        # get val_list for this particular bet
        val_info = Get(ctx, concatkey(bet, VAL_PREFIX))
        val_list = Deserialize(val_info)

        # get the rep info
        rep_info = Get(ctx, REPKEY)
        rep_map = Deserialize(rep_info)

        # check if user agrees or disagrees with bet
        if for_against:
            # maps user to amount staked
            add_map(bet, address, amount_staked, FM_PREFIX)
            add_user_list(bet, address, FL_PREFIX)

            # update for staked
            val_list[2] += amount_staked

            # update for count
            val_list[4] += 1

            # update for rep
            val_list[0] += rep_map[address]
            
            # update for avg rep 
            val_list[11] = val_list[0] / val_list[4]
            
            Notify(['For values updated'])
        else:
            # if people have already voted against this bet, take this action:
            if Get(ctx, concatkey(bet, AL_PREFIX)):
                add_map(bet, address, amount_staked, AM_PREFIX)
                add_user_list(bet, address, AL_PREFIX)
                Notify(['Existing against_map and against_list'])

            # if not, create, update, and store against map and list for this bet
            else:
                against_map = {}
                against_list = []

                against_map[address] = bank_map[address]
                against_list.append(address)

                am_info = Serialize(against_map)
                al_info = Serialize(against_list)
                Put(ctx, concatkey(bet, AM_PREFIX), am_info)
                Put(ctx, concatkey(bet, AL_PREFIX), al_info)
                Notify(['against_map and against_list inited'])

            # update against staked
            val_list[3] += amount_staked

            # update against count
            val_list[5] += 1

            # update against rep
            val_list[1] += rep_map[address]
            
            # update against avg rep 
            val_list[12] = val_list[1] / val_list[5]
            Notify(['Against values updated'])
        
        # update probability
        val_list[13] = FACTOR * val_list[2] / (val_list[2] + val_list[3]) * 100
        # put val_list back onchain
        val_info = Serialize(val_list)
        Put(ctx, concatkey(bet, VAL_PREFIX), val_info)

        # update wallet and bank ledger, put latter back onchain
        bank_map[address] -= amount_staked
        bank_info = Serialize(bank_map)
        Put(ctx, BANKEY, bank_info)
        Notify(['bank_map updated'])

        subtract_bank(address, amount_staked)
        Notify(['user wallet updated'])

        bet_list.append(bet)
        bl_info = Serialize(bet_list)
        Put(ctx, concatkey(address, BL_PREFIX), bl_info)
        Notify(['User bet list updated'])

        # update track record
        record_info = Get(ctx, concatkey(address, RC_PREFIX))
        if record_info:
            record_map = Deserialize(record_info)
        else:
            record_map = {}
        
        # bet in progress
        record_map[concatkey(bet, BT_PREFIX)] = 1
        record_info = Serialize(record_map)
        Put(ctx, concatkey(address, RC_PREFIX), record_info)
        Notify(['User track record updated'])
        
        # update profit per bet info
        profit_info = Get(ctx, concatkey(address, PT_PREFIX))
        if profit_info:
            profit_map = Deserialize(profit_info)
        else:
            profit_map = {}
        
        # 0 profit so far for this bet because the bet is still ongoing
        profit_map[concatkey(bet, BT_PREFIX)] = 0
        profit_info = Serialize(profit_map)
        Put(ctx, concatkey(address, PT_PREFIX), profit_info)
        
        Notify(['vote', bet, val_list])
        

        return True
Exemple #11
0
def user_record(address):
    byte_address = Base58ToAddress(address)
Exemple #12
0
def user_tab(address):
    byte_address = Base58ToAddress(address)
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 = Base58ToAddress('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
Exemple #14
0
from ontology.interop.System.Storage import GetContext, Get, Put, Delete
from ontology.interop.System.Runtime import Notify, CheckWitness, GetTime
from ontology.interop.System.Action import RegisterAction
from ontology.builtins import concat
from ontology.interop.Ontology.Runtime import Base58ToAddress

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

ctx = GetContext()

NAME = 'OEP4 Template'
SYMBOL = 'OEP4T'
DECIMALS = 9
FACTOR = 1000000000
OWNER = Base58ToAddress("AQf4Mzu1YJrhz9f3aRkkwSm9n3qhXGSh4p")

TOTAL_AMOUNT = 10000
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':
Exemple #15
0
OntCversion = '2.0.0'

from ontology.interop.Ontology.Runtime import Base58ToAddress
from ontology.interop.System.App import DynamicAppCall
from ontology.interop.System.ExecutionEngine import GetExecutingScriptHash, GetCallingScriptHash
from ontology.interop.System.Runtime import CheckWitness
from ontology.interop.System.Storage import GetContext, Put, Get
from ontology.libont import bytearray_reverse

from ont_contracts.chainlink import *

CURRENT_PRICE = 'CurrentPrice'
CHAINLINK_CLIENT = 'ChainlinkClient'

OWNER = Base58ToAddress('AbG3ZgFrMK6fqwXWR1WkQ1d1EYVunCwknu')

ContractAddress = GetExecutingScriptHash()


def Main(operation, args):
    if operation == 'requestEthereumPrice':
        assert (len(args) == 3)
        oracle = args[0]
        jobId = args[1]
        payment = args[2]
        return requestEthereumPrice(oracle, jobId, payment)

    if operation == 'fulfill':
        assert (len(args) == 2)
        requestId = args[0]
        price = args[1]
from ontology.interop.System.Action import RegisterAction

from ontology.interop.Ontology.Runtime import Base58ToAddress
from ontology.builtins import concat, len, append, remove

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

# modify to the admin address
CEO_ADDRESS_KEY = "CEO"
CTO_ADDRESS_KEY = "CTO"
COO_ADDRESS_KEY = "COO"
AUTHORIZED_ADDRESS_LIST_KEY = "AuthorizedAddress"
CEOAddress = Base58ToAddress('AQf4Mzu1YJrhz9f3aRkkwSm9n3qhXGSh4p')

CONTRACT_PAUSED_KEY = "Pause"
# NAME_PREFIX + tokenId --- to store the name of the tokenId token
NAME_PREFIX = 'Name'
# SYMBOL_PREFIX + tokenId --- to store the symbol of the tokenId token
SYMBOL_PREFIX = 'Symbol'
#  BALANCE_PREFIX + tokenId + address --- to store the balance of address in terms of the TOKEN_ID token
BALANCE_PREFIX = 'Balance'
# APPROVE_PREFIX + tokenId + owner + spender -- to store the approved TOKEN_ID amount to the spender by the owner
APPROVE_PREFIX = 'Approve'
# TOTAL_SUPPLY + tokenId  --- to store the total supply of the TOKEN_ID token
TOTAL_SUPPLY_PREFIX = 'TotalSupply'


def Main(operation, args):
Exemple #17
0
OntCversion = '2.0.0'

from ontology.interop.Ontology.Runtime import Base58ToAddress
from ontology.interop.System.Action import RegisterAction
from ontology.interop.System.Runtime import Log, CheckWitness
from ontology.interop.System.Storage import GetContext, Get, Put, Delete
ctx = GetContext()

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

OWNER = Base58ToAddress("ATwo3VeAj4JnDY2uP1aKWS4p5LhyFHJeiE")

NAME = 'Demo Token'
SYMBOL = 'Demo'
DECIMALS = 8
TOTAL_AMOUNT = 100000000 # 100 million
DECIMAL_MULTIPLIER = 100000000 # 10^{DECIMALS} = 10^8

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


def Main(operation, args):
    if operation == 'name':
        Require(len(args) == 0)
        return name()
    elif operation == 'symbol':
        Require(len(args) == 0)
        return symbol()