from boa.interop.Neo.Runtime import Notify from boa.interop.Neo.Action import RegisterAction Event = RegisterAction('Event', 'Number', 'String') def Main(): integer = 1 string = "hello" Event(integer,string) Notify(integer,string)
from boa.interop.Neo.Runtime import CheckWitness, Log from boa.interop.Neo.Action import RegisterAction from boa.interop.Neo.Storage import * from boa.builtins import concat from nodis.token import * from nodis.nep5 import do_transfer_from from nodis.challenge.challenge import create_challenge, submit, close_challenge, check_challenge_package, buy_challenge_package, is_challenge_closed, is_challenge_open, submission_number, challenge_expiry_date from nodis.submission.submission import create_submission, approve, reject, promoter_fund_claim, rejecter_fund_claim, submission_approver_number, submission_rejecter_number, submission_expiry_date from utils import valid_address OnTransfer = RegisterAction('transfer', 'addr_from', 'addr_to', 'amount') OnApprove = RegisterAction('approve', 'addr_from', 'addr_to', 'amount') def generate_business_key(address): return concat(b'Business:', address) def register(ctx, address): key = generate_business_key(address) Put(ctx, key, b'1') return True def check(ctx, address): key = generate_business_key(address) status = Get(ctx, key) return status == b'1'
from boa.interop.Neo.Runtime import CheckWitness from boa.interop.Neo.Action import RegisterAction from boa.interop.Neo.Storage import Get, Put from boa.builtins import concat from spot.token import * from spot.txio import get_asset_attachments from spot.time import get_now OnKYCRegister = RegisterAction('kyc_registration', 'address') OnTransfer = RegisterAction('transfer', 'addr_from', 'addr_to', 'amount') OnRefund = RegisterAction('refund', 'addr_to', 'amount') # Add address as private placement, has implications on withdrawl # and allow minting more than 1 million tokens def add_private_placement(ctx, address): print("Adding private placement address") if CheckWitness(TOKEN_OWNER): if len(address) == 20: storage_key = concat(PP_KEY, address) Put(ctx, storage_key, True) return True return False # Check if address already in private placement list def is_private_placement(ctx, address): storage_key = concat(PP_KEY, address) if Get(ctx, storage_key): return True
from boa.interop.Neo.Runtime import CheckWitness from boa.interop.Neo.Action import RegisterAction from boa.interop.Neo.Storage import Get, Put, Delete from boa.builtins import concat from asa.token import TOKEN_OWNER from asa.utils.txio import get_asset_attachments OnKYCRegister = RegisterAction('kycRegister', 'address') OnKycDeregister = RegisterAction('kycDeregister', 'address') KYC_KEY = b'kyc_ok' KYC_ADMIN_KEY = b'kyc_admin' def kyc_register(ctx, args): """ Register a list of addresses for KYC :param ctx:GetContext() used to access contract storage :param args:list a list of addresses to register. If called by KYC admin that is not token owner, first address must be address of KYC admin. :return:int The number of addresses registered for KYC """ ok_count = 0 canRegister = CheckWitness(TOKEN_OWNER) if not canRegister and get_kyc_admin_status(ctx, args[0]) and CheckWitness(
GetEntryScriptHash, GetExecutingScriptHash) # This is the script hash of the address for the owner of the contract # This can be found in ``neo-python`` with the wallet open, # use ``wallet`` command # TOKEN_CONTRACT_OWNER = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' # TOKEN_CONTRACT_OWNER = b'\x0f&\x1f\xe5\xc5,k\x01\xa4{\xbd\x02\xbdM\xd3?\xf1\x88\xc9\xde' TOKEN_CONTRACT_OWNER = b'#\xba\'\x03\xc52c\xe8\xd6\xe5"\xdc2 39\xdc\xd8\xee\xe9' TOKEN_NAME = 'SyringeTender' TOKEN_SYMBOL = 'SYRN' TOKEN_CIRC_KEY = b'in_circulation' TOKEN_DECIMALS = 100 # max 100 companies can participate in tender. # Smart Contract Event Notifications OnApprove = RegisterAction('approve', 'addr_from', 'addr_to', 'amount') OnNFTApprove = RegisterAction('NFTapprove', 'addr_from', 'addr_to', 'tokenid') OnTransfer = RegisterAction('transfer', 'addr_from', 'addr_to', 'amount') OnNFTTransfer = RegisterAction('NFTtransfer', 'addr_from', 'addr_to', 'tokenid') OnMint = RegisterAction('mint', 'addr_to', 'amount') OnNFTMint = RegisterAction('NFTmint', 'addr_to', 'tokenid') # common errors ARG_ERROR = 'incorrect arg length' INVALID_ADDRESS_ERROR = 'invalid address' PERMISSION_ERROR = 'incorrect permission' TOKEN_DNE_ERROR = 'token does not exist' def Main(operation, args):
from boa.builtins import list # ------------------------------------------- # DAPP SETTINGS # ------------------------------------------- OWNER = b'#\xba\'\x03\xc52c\xe8\xd6\xe5"\xdc2 39\xdc\xd8\xee\xe9' DEPOSIT_WALLET = b'ZPH\xa84\xf1Y\x14\xf1\x91b\x95\x85\xd1\xba\x96\x81\x99\x1f\xd3' QUARK_WALLET = b'\xa9u\xfcZ\xb9\xa2\x8c\xeey\xf6\x92\xeeG-\x1a\xf8T\xb5\xbcH' # Script hash of the token owner # ------------------------------------------- # Events # ------------------------------------------- # DispatchOrderEvent = RegisterAction('order-add', 'order_key') DispatchExchangeEvent = RegisterAction('exchange', 'order_key') DispatchResultNoticeEvent = RegisterAction('result-notice', 'order_key', 'weather_param', 'oracle_cost') DispatchClaimEvent = RegisterAction('pay-out', 'order_key') DispatchTransferEvent = RegisterAction('transfer', 'from', 'to', 'amount') DispatchRefundAllEvent = RegisterAction('refund-all', 'order_key') DispatchDeleteOrderEvent = RegisterAction('order-delete', 'order_key') def Main(operation, args): """ This is the main entry point for the dApp :param operation: the operation to be performed :type operation: str :param args: an optional list of arguments
from boa.interop.Neo.Runtime import Log, GetTrigger, CheckWitness from boa.interop.Neo.Storage import GetContext, Get, Put, Delete from boa.interop.Neo.Action import RegisterAction Push = RegisterAction('event', 'operation', 'msg') def Main(operation, args): if operation == 'Query': domain = args[0] return Query(domain) if operation == 'Register': domain = args[0] owner = args[1] return Register(domain, owner) if operation == 'Transfer': domain = args[0] to = args[1] return Transfer(domain, to) if operation == 'Delete': domain = args[0] return Delete(domain) return False def Query(domain): context = GetContext()
# ------------------------------------------- # CONTEXT # ------------------------------------------- ctx = GetContext() # ------------------------------------------- # SETTINGS # ------------------------------------------- OWNER = b'#\xba\'\x03\xc52c\xe8\xd6\xe5"\xdc2 39\xdc\xd8\xee\xe9' MAX_HP = 10 OnBattleRound = RegisterAction('battle_step','battle_id', 'battle_round', 'player1_addr', 'player2_addr', 'player1_action', 'player2_action', 'player1_hp', 'player2_hp') OnBattleResult = RegisterAction('battle_result','battle_id', 'winner', 'competition', 'competition_step') OnBattlePlayers = RegisterAction('battle_players','player1', 'player2') def Main(operation, args): # The trigger determines whether this smart contract is being # run in 'verification' mode or 'application' trigger = GetTrigger() if trigger == Verification(): return False # 'Application' mode elif trigger == Application():
from boa.interop.Neo.Runtime import Serialize, Deserialize, CheckWitness from boa.interop.Neo.Action import RegisterAction from boa.interop.Neo.Storage import Get, Put, Delete, GetContext from boa.builtins import concat from nash.owner import check_owners # Whitelist events onAddedToWhitelist = RegisterAction('OnAddedToWhitelist', 'address') onRemovedFromWhitelist = RegisterAction('OnRemovedFromWhitelist', 'address') onAddedWhitelistAdmin = RegisterAction('OnAddedWhitelistAdmin', 'address') onRemovedWhitelistAdmin = RegisterAction('OnRemovedWhitelistAdmin', 'address') # Whitelist prefixes Prefix_KYCAccount = b'accountKycOk' KYC_Admin_Key = b'kycAdminList' ctx = GetContext() def sanitizeAddress(addr): """ Checks whether a bytearray is of length 20 Args: addr (bytearray): an address to be sanitized Returns: addr (bytearray): sanitized address """
from boa.interop.Neo.Blockchain import GetHeight from boa.interop.Neo.Runtime import CheckWitness from boa.interop.Neo.Action import RegisterAction from boa.interop.Neo.Storage import Get, Put from boa.builtins import concat from asa.token import * from asa.utils.txio import get_asset_attachments from asa.utils.time import get_now OnMintTokens = RegisterAction('mintTokens', 'addr_from', 'addr_to', 'amount') OnRefund = RegisterAction('refund', 'addr_to', 'amount') SALE_STATUS_KEY = b'sale_status' LIMITSALE_ROUND = b'limit_sale' CROWDSALE_BONUS_ROUND = b'crowd_sale_bonus' CROWDSALE_ROUND = b'crowd_sale' SALE_END = b'sale_end' SALE_PAUSED = b'sale_paused' LIMITSALE_NEO_MIN = 1 * 100_000_000 # NEO * 10^8 LIMITSALE_NEO_MAX = 50 * 100_000_000 # NEO * 10^8 CROWDSALE_NEO_MIN = 1 * 100_000_000 # NEO * 10^8 CROWDSALE_NEO_MAX = 500 * 100_000_000 # NEO * 10^8 CROWDSALE_LARGE_CONTRIBUTION = 100 * 100_000_000 # NEO * 10^8 LIMITSALE_TOKENS_PER_NEO = 6000 # 6000 Tokens/NEO (5000*1.2=6000) CROWDSALE_BONUS_ROUND_TOKENS_PER_NEO = 5750 # 5750 Tokens/NEO (5000*1.15=5750) CROWDSALE_LARGE_CONTRIBUTION_TOKENS_PER_NEO = 5500 # 5500 Tokens/NEO (5000*1.1=5500)
""" Fee Pool module - handling stored fees """ from boa.interop.Neo.Runtime import Notify from boa.interop.Neo.Action import RegisterAction from nas.wrappers.storage import storage_load, storage_save CollectedFeesChangedEvent = RegisterAction('collectedFeesChanged', 'total_collected') """ Its fee pool implementation. \n: - takes care of collecting fees: \n: - takes care of redistributing fees to stakers: \n staking not yet implemented """ def get_collected_fees(): """ :returns total of collected fees (not redistributed): """ collected = storage_load("collected_fees_in_pool") return collected def add_fee_to_pool(to_add): """ :parama to_add: \nadds fees to pool """ # I guess compiler messes with datatypes badly, # because 0 is here > 0 ?! if to_add > 0:# and to_add != 0:
from boa.interop.Neo.Runtime import GetTrigger, CheckWitness from boa.interop.Neo.TriggerType import Application, Verification from boa.interop.System.ExecutionEngine import GetExecutingScriptHash, GetCallingScriptHash from boa.interop.Neo.Blockchain import GetHeight from boa.interop.Neo.Action import RegisterAction from boa.interop.Neo.App import RegisterAppCall from boa.interop.Neo.Storage import * ctx = GetContext() TUT_Scripthash = b"\x82N\xca\xfd\xcd\xd91}\xd8\xb2`\x89\xfb|\x88x\xdb\xc2\'\xae" OWNER = b'\xdc\xcbK\xc2\xeb4TV\xe0\x15\xf9>|\t\xad\xfa\xcc\xea\x1ez' KOTH_KEY = b'TheKing' INCREMENT = 1000000000 KingNotify = RegisterAction('new_king', 'address', 'next_bounty', 'king_name') TUT_Contract = RegisterAppCall('ae27c2db78887cfb8960b2d87d31d9cdfdca4e82', 'operation', 'args') def Main(operation, args): trigger = GetTrigger() if trigger == Verification(): if CheckWitness(OWNER): return True return False elif trigger == Application():
from boa.interop.Neo.Runtime import GetTime, Serialize, Deserialize, Notify from boa.interop.Neo.Storage import Get, Put from boa.interop.Neo.Action import RegisterAction from storage.StorageHelper import PutThree, GetThree, IncrementOne #events OnRegister = RegisterAction('register', 'addr', 'uid') def register(ctx, args): """ Register new account Args: 0 -> script hash of invoker 1 -> unique user id 2 -> display name 3 -> public key Account storage uid => array[]: 0 -> script hash of invoker 1 -> uid 2 -> display name 3 -> time of registration 4 -> count tweets 5 -> count followers 6 -> count following 7 -> count unfollowed 8 -> count unfollowing 9 -> public key """ addr = args[0]
""" Module Trade - alias trading implementation """ from boa.interop.Neo.Runtime import Notify, CheckWitness from boa.interop.Neo.Action import RegisterAction from boa.builtins import concat from nas.config.service import * from nas.common.fee_pool import add_fee_to_pool, get_collected_fees from nas.common.alias import * from nas.common.util import return_value, get_header_timestamp SellOfferEvent = RegisterAction('putOnSale', 'alias_name', 'alias_type', 'price') CancelSellOfferEvent = RegisterAction('cancelOnSale', 'alias_name', 'alias_type') BuyOfferEvent = RegisterAction('buyOffer', 'alias_name', 'alias_type', 'offer_owner', 'price') CancelBuyOfferEvent = RegisterAction('cancelBuyOffer', 'alias_name', 'alias_type', 'offer_owner') TradeSuccesfullEvent = RegisterAction('trade', 'alias_name', 'alias_type', 'old_owne', 'new_owner', 'price') def offer_sell(alias, args): """ :param alias: \n:param args [price, type]: \n:returns True if success or False if failed: """ nargs = len(args)
KYC_KEY = b'kyc_ok' BURN_KEY = b'burn_tokens' # LIMITED_ROUND_KEY = b'r1' # NO LIMITED ROUND ANYMORE !!! # TODO make sure the current bonus structure is correct BOUNS = [ [11520, 20], # 20% for the first 48hrs = 48 * 60 * 60 / 15 [40320, 10], # 10% for the 1st week = 7 * 24 * 60 * 60 / 15 [80640, 7], # 7% for the 2nd week = 14 * 24 * 60 * 60 / 15 [120960, 3], # 3% for the 3rd week = 21 * 24 * 60 * 60 / 15 ] OnBurn = RegisterAction('burn', 'amount') def crowdsale_available_amount(ctx): """ :return: int The amount of tokens left for sale in the crowdsale """ in_circ = Get(ctx, TOKEN_CIRC_KEY) available = TOKEN_TOTAL_SUPPLY - in_circ return available
INITIAL_POOL = 5000000 * 100000000 # 5m FTW # -- NEP5 variables TOKEN_NAME = 'For The Win' SYMBOL = 'FTW' DECIMALS = 8 TOTAL_SUPPLY = 100000000 * 100000000 # 100m total supply * 10^8 (decimals) OWNER = b'\xdc\xf3\xca\xef\xf9\xbb;\xf1\xf0?\xbb\x18\x81\x9cj\xba\x98r\xdc\xe4' POOL = b'<R\xe3\x1d\x07\nX\x174\x97\x17\xa6V*\x0c\xa2>\xa6\xe2\xeb' # ------------------------------------------- # Events NEP5 # ------------------------------------------- DispatchTransferEvent = RegisterAction('transfer', 'from', 'to', 'amount') # ------------------------------------------- # Events FTW # ------------------------------------------- DispatchBuyEvent = RegisterAction('buy', 'from', 'ticket_no', 'no_1', 'no_2', 'no_3', 'no_4', 'no_5') DispatchDrawEvent = RegisterAction('draw', 'from', 'game_no') DispatchVerifyEvent = RegisterAction('verify', 'from', 'ticket_no') def Main(operation, args): trigger = GetTrigger()
from boa.interop.Neo.Runtime import CheckWitness from boa.interop.Neo.Storage import GetContext, Get, Put from boa.interop.Neo.Action import RegisterAction # AVFobKv2y7i66gbGPAGDT67zv1RMQQj9GB TOKEN_OWNER = b'\x93\xe1\xe5\xbe\xd9\x15\x96\x84\xac\x8c.\xe4\r w\xfb\xcf\xac\xf7\n' TOTAL_SUPPLY = 10000000 * 100000000 TOKEN_NAME = 'My First Token' TOKEN_SYMBOL = 'MFT' TOKEN_DECIMALS = 8 TOTAL_SUPPLY_KEY = 'TOTAL_SUPPLY' INIT_KEY = 'DEPLOYED' ctx = GetContext() OnTransfer = RegisterAction('transfer', 'addr_from', 'addr_to', 'amount') def Main(operation, args): if operation == 'totalSupply': return Get(ctx, TOTAL_SUPPLY_KEY) if operation == 'name': return TOKEN_NAME if operation == 'symbol': return TOKEN_SYMBOL if operation == 'decimals': return TOKEN_DECIMALS
from boa.interop.Neo.Runtime import Notify, Log, GetTime, Serialize, Deserialize from boa.builtins import concat, list from boa.interop.Neo.Storage import Get from boa.interop.Neo.Action import RegisterAction from storage.StorageHelper import IncrementThree, PutThree, IncrementOne, PutTwo, updateTweetCount, updateAccCount, GetThree # events OnTweet = RegisterAction('tweet', 'globalid', 'uid', 'tweetkey') OnRetweet = RegisterAction('retweet', 'uid', 'retweetkey') OnComment = RegisterAction('comment', 'uid', 'tweetkey') OnLike = RegisterAction('like', 'uid', 'tweetkey') def sendMessage(ctx, args): # Args sender = args[0] receiver = args[1] # messageA: for "encrypt-to-self". encrypted with public key from A (sender). messageA = args[2] # messageB: encrypted with public key from B (receiver). messageB = args[3] time = GetTime() Log('time') Notify(concat('time', time)) """ Sender A = scripthash of sender storage A.send.{index} stores the sent message from A for respective index storage A.send.latest stores the index of the last message sent from A
from boa.interop.Neo.Runtime import Notify, GetTrigger, Log, CheckWitness, Deserialize, Serialize from boa.interop.Neo.Storage import Get, Put, Delete, GetContext from boa.interop.Neo.TriggerType import Verification, Application from boa.interop.System.ExecutionEngine import GetScriptContainer, GetExecutingScriptHash from boa.interop.Neo.Transaction import Transaction, GetReferences from boa.interop.Neo.Output import GetValue, GetAssetId, GetScriptHash from boa.interop.BigInteger import BigInteger, ONE from boa.interop.Neo.Action import RegisterAction gas_asset_id = b'\xe7-(iy\xeel\xb1\xb7\xe6]\xfd\xdf\xb2\xe3\x84\x10\x0b\x8d\x14\x8ewX\xdeB\xe4\x16\x8bqy,`' neo_asset_id = b'\x9b|\xff\xda\xa6t\xbe\xae\x0f\x93\x0e\xbe`\x85\xaf\x90\x93\xe5\xfeV\xb3J\\"\x0c\xcd\xcfn\xfc3o\xc5' token_owner = b'#\xba\'\x03\xc52c\xe8\xd6\xe5"\xdc2 39\xdc\xd8\xee\xe9' OnBet = RegisterAction('OnBet', "from_address", "bet_id", "option", "amount") context = GetContext() # NEO betting is used for demonstration purpose. # Case: # 1/ User bet by sending same amount of NEO and content to smart contract, # smc then store user info (address, option) then broadcast event onBet def get_asset_attachments(): """ Gets information about NEO and Gas attached to an invocation TX :return: list: A list with information about attached neo and gas """ tx = GetScriptContainer() references = tx.References
from boa.interop.Neo.Runtime import Notify, GetTrigger, Log, CheckWitness, Deserialize, Serialize from boa.interop.Neo.Storage import Get, Put, Delete, GetContext from boa.interop.Neo.TriggerType import Verification, Application from boa.interop.System.ExecutionEngine import GetScriptContainer, GetExecutingScriptHash from boa.interop.Neo.Transaction import Transaction, GetReferences from boa.interop.Neo.Output import GetValue, GetAssetId, GetScriptHash from boa.interop.BigInteger import BigInteger, ONE from boa.interop.Neo.Action import RegisterAction gas_asset_id = b'\xe7-(iy\xeel\xb1\xb7\xe6]\xfd\xdf\xb2\xe3\x84\x10\x0b\x8d\x14\x8ewX\xdeB\xe4\x16\x8bqy,`' neo_asset_id = b'\x9b|\xff\xda\xa6t\xbe\xae\x0f\x93\x0e\xbe`\x85\xaf\x90\x93\xe5\xfeV\xb3J\\"\x0c\xcd\xcfn\xfc3o\xc5' token_owner = b'#\xba\'\x03\xc52c\xe8\xd6\xe5"\xdc2 39\xdc\xd8\xee\xe9' OnEvent = RegisterAction('OnEvent', 'receiver', 'sender', 'sent_neo', 'sent_gas') OnDeposit = RegisterAction('OnDeposit', 'type', 'amount', 'receiver', 'rate') OnRelease = RegisterAction('OnRelease', 'type', 'amount', 'receiver') context = GetContext() def get_asset_attachments(): """ Gets information about NEO and Gas attached to an invocation TX :return: list: A list with information about attached neo and gas """ tx = GetScriptContainer() references = tx.References
from ret.token.kyc import get_kyc_status from boa.builtins import concat from boa.interop.Neo.Storage import Get, Put from boa.interop.Neo.Action import RegisterAction from ret.common.other import * OnAffiliate = RegisterAction('affiliate', 'sender_addr', 'referer_addr', 'amount') AFFILIATE_MAX_CAP = 13625000 * 100000000 # 13.625M AFFILIATE_RATE = 25 # divide 1000 = 2.5% def do_affiliate(ctx, sender_addr, amount): referrer_addr = get_referrer(ctx, sender_addr) if not referrer_addr: return False if not get_kyc_status(ctx, referrer_addr): return False amount = amount * AFFILIATE_RATE / 1000 ''' Check affiliate tokens ''' if get_balance(ctx, AFFILIATE_FUNDS_ADDRESS) < amount: return False affiliated_tokens = get_affiliated_tokens(ctx)
from boa.interop.System.ExecutionEngine import (GetCallingScriptHash, GetEntryScriptHash, GetExecutingScriptHash) # This is the script hash of the address for the owner of the contract # This can be found in ``neo-python`` with the wallet open, # use ``wallet`` command # TOKEN_CONTRACT_OWNER = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' # TOKEN_CONTRACT_OWNER = b'\x0f&\x1f\xe5\xc5,k\x01\xa4{\xbd\x02\xbdM\xd3?\xf1\x88\xc9\xde' TOKEN_CONTRACT_OWNER = b'#\xba\'\x03\xc52c\xe8\xd6\xe5"\xdc2 39\xdc\xd8\xee\xe9' TOKEN_NAME = 'Identity Token' TOKEN_SYMBOL = 'IDK' TOKEN_CIRC_KEY = b'in_circulation' # Smart Contract Event Notifications OnMint = RegisterAction('mint', 'addr_to') OnIDKMint = RegisterAction('NFTmint', 'addr_to') # common errors ARG_ERROR = 'incorrect arg length' INVALID_ADDRESS_ERROR = 'invalid address' PERMISSION_ERROR = 'incorrect permission' TOKEN_DNE_ERROR = 'token does not exist' def Main(operation, args): """Entry point to the program :param str operation: The name of the operation to perform :param list args: A list of arguments along with the operation :return: The result of the operation
RECORD_ID_DATA_PREFIX = 'ridd_' NEXT_RECORD_ID_KEY = 'next_rid' ORDER_ID_LIST_PREFIX = 'oidl_' ORDER_ID_PREFIX = 'orid_' NEXT_ORDER_ID_KEY = 'next_oid' # Messages UNKNOWN_OP = 'unknown operation' WRONG_ARGS = 'wrong arguments' # Const values INITIAL_ID = 1 # Events DispatchTransferEvent = RegisterAction('transfer', 'from', 'to', 'amount') def Main(operation, args): """ This is the main entry point for the dApp :param operation: the operation to be performed :type operation: str :param args: an optional list of arguments :type args: list :return: indicating the successful execution of the dApp :rtype: str """ # <<< USER CRUD METHODS >>> if operation == 'getUserList': if len(args) == 0:
from boa.interop.Neo.Runtime import CheckWitness from boa.interop.Neo.Action import RegisterAction from boa.builtins import concat from boa.interop.Neo.Storage import * from xqt.common import * from xqt.serialization import deserialize_bytearray, serialize_array from xqt.user_service import USER_PROP_KEY, get_properties_user, get_user_info OnPropRegist = RegisterAction('prop_registration', 'prop_id') OnPropUpdate = RegisterAction('prop_update', 'prop_id') OnPropDeletion = RegisterAction('prop_delete', 'prop_id') PROP_INFO_KEY = b'prop_info' PROP_OWNER_KEY = b'prop_owner' args_incorrect_len = 'incorrect args length' def handle_prop(ctx, operation, args): if operation == 'prop_info': if len(args) == 1: return get_prop_info(ctx,args[0]) return args_incorrect_len elif operation == 'prop_owner': if len(args) == 1: return get_prop_owner(ctx,args[0]) return args_incorrect_len elif operation == 'register_prop': if len(args) == 3: if len(args[2]) != 20:
from boa.interop.Neo.Runtime import CheckWitness, GetTime from boa.interop.Neo.Action import RegisterAction from ret.token.rettoken import * from ret.common.txio import get_asset_attachments from ret.token.affiliate import * from ret.common.other import * OnTransfer = RegisterAction('transfer', 'addr_from', 'addr_to', 'amount') OnRefund = RegisterAction('refund', 'addr_to', 'amount') # STATE IS_NOT_SALE = 0 IS_WHITELIST_SALE = 1 IS_PRESALE = 2 IS_CROWDSALE = 3 # HARD CONFIG WHITELIST_SALE_MAX_CAP = 70000000 * 100000000 # 70M WHITELIST_SALE_THRESHOLD = 400 * 100000000 # 400 NEO # WHITELIST_SALE_PERSONAL_CAP = 500 * 100000000 # 500 NEO PRESALE_MAX_CAP = 65000000 * 100000000 # 65M # PRESALE_PERSONAL_CAP = 250 * 100000000 # 250 NEO CROWDSALE_MAX_CAP = 480000000 * 100000000 # 480M # CROWDSALE_PERSONAL_CAP = 500 * 100000000 # 500 NEO def perform_exchange(ctx): """
""" Module configuration - contains NA root configuration """ from boa.interop.Neo.Runtime import Notify, CheckWitness from boa.interop.Neo.Action import RegisterAction from nas.common.constants import * from nas.common.acc import add_account_available_assets ConfigurationUpdatedEvent = RegisterAction('configurationUpdated', 'option', 'value') """ :Interface to access NEO Alias configuration: \n :Configuration will be determined based on voting mechanism, that will be implemented later: \n Final implementation will prevent centralized control and except init() method for initial setup, configuration is going to be controloble only trough voting """ def init_NA_service(): """ :Initializes dapp NASC: """ if not CheckWitness(ROOT_ADMIN): msg = "Only root_admin can initialize NASC." Notify(msg) return msg # initialize dummy = storage_save("NASC_initialized", True) #init for testing if DEBUG:
from boa.interop.Neo.TriggerType import Application, Verification from boa.interop.Neo.Storage import GetContext, Get, Put, Delete from boa.interop.System.ExecutionEngine import GetCallingScriptHash from boa.builtins import concat TOKEN_NAME = 'SEA Coin' SYMBOL = 'SEAC' OWNER = b'%\xc8J\x12\xdd\xf7\xe6?\x96\x7f\xfd\x01\xf5F\xef\xf0\xe7\xad\xd0\x9a' DECIMALS = 8 TOTAL_SUPPLY = 10000000000000000 DISTRIBUTE_TO_BLOCK = 9000000000000000 DISTRIBUTE_TO_ME = 1000000000000000 DispatchTransferEvent = RegisterAction('transfer', 'from', 'to', 'amount') DispatchApproveEvent = RegisterAction('approval', 'owner', 'spender', 'value') ctx = GetContext() def Main(operation, args): """ This is the main entry point for the Smart Contract :param operation: the operation to be performed ( eg `balanceOf`, `transfer`, etc) :type operation: str :param args: a list of arguments ( which may be empty, but not absent ) :type args: list :return: indicating the successful execution of the smart contract
from boa.interop.Neo.Blockchain import GetHeight from boa.interop.Neo.Runtime import CheckWitness from boa.interop.Neo.Action import RegisterAction from boa.interop.Neo.Storage import Get, Put from boa.builtins import concat from xqt.token import * from xqt.common import * from xqt.txio import get_asset_attachments # OnInvalidKYCAddress = RegisterAction('invalid_registration', 'address') OnKYCRegister = RegisterAction('kyc_registration', 'address') OnTransfer = RegisterAction('transfer', 'addr_from', 'addr_to', 'amount') OnContribution = RegisterAction('contribution', 'from', 'neo', 'gas', 'tokens') OnRefund = RegisterAction('refund', 'addr_to', 'amount') OnPreSaleMint = RegisterAction('presale_mint', 'to', 'neo', 'tokens') KYC_KEY = b'kyc_ok' def kyc_register(ctx, args): """ :param args:list a list of addresses to register :param token:Token A token object with your ICO settings :return: int: The number of addresses to register for KYC """ ok_count = 0 if CheckWitness(TOKEN_OWNER):
from boa.interop.Neo.Blockchain import GetHeight from boa.interop.Neo.Runtime import CheckWitness from boa.interop.Neo.Action import RegisterAction from boa.interop.Neo.Storage import Get, Put from boa.builtins import concat from txio import * OnKYCRegister = RegisterAction('kyc_registration', 'address') KYC_KEY = b'kyc_ok' OWNER = b'#\xba\'\x03\xc52c\xe8\xd6\xe5"\xdc2 39\xdc\xd8\xee\xe9' def kyc_register(ctx, address): kyc_storage_key = concat(KYC_KEY, address) Put(ctx, kyc_storage_key, True) OnKYCRegister(address) return True def sender_is_in_DAO(ctx): attachments = get_asset_attachments() print("user", attachments[1]) if not get_kyc_status(ctx, attachments[1]): return False return True def get_kyc_status(ctx, address): print("checking kyc status") kyc_storage_key = concat(KYC_KEY, address)
from boa.interop.Neo.Storage import GetContext, Get, Put, Delete from boa.interop.Neo.Action import RegisterAction from boa.interop.Neo.Enumerator import EnumeratorCreate, EnumeratorNext # Compiler includes from boa.builtins import concat # Storage context for local contract context = GetContext() # Static administrative address admin = b'\xae\xe7O\xf1\x02\xbb$CL\xb0\xd5\x17pD\xadx\xc1C\xfa\x90' burn = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' # Set notification triggers OnTransfer = RegisterAction('transfer', 'address', 'to', 'amount') OnApprove = RegisterAction('approve', 'address', 'to', 'amount') # Main function def Main(operation, arguments): # Get the contract trigger type trigger = GetTrigger() # Contract transaction if trigger == Verification(): if CheckWitness(admin): return True