from boa.blockchain.vm.Neo.Runtime import Log, Notify from boa.blockchain.vm.System.ExecutionEngine import GetScriptContainer, GetExecutingScriptHash from boa.blockchain.vm.Neo.Transaction import * from boa.blockchain.vm.Neo.Blockchain import GetHeight, GetHeader from boa.blockchain.vm.Neo.Action import RegisterAction from boa.blockchain.vm.Neo.Runtime import GetTrigger, CheckWitness from boa.blockchain.vm.Neo.TriggerType import Application, Verification from boa.blockchain.vm.Neo.Output import GetScriptHash, GetValue, GetAssetId from boa.blockchain.vm.Neo.Storage import GetContext, Get, Put, Delete from boa.blockchain.vm.Neo.Header import GetTimestamp, GetNextConsensus 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]
from boa.blockchain.vm.Neo.Action import RegisterAction Transfer = RegisterAction('transfer', 'from', 'to', 'amount') Refund = RegisterAction('refund', 'to', 'amount') def Main(): """ :return: """ a = 2 b = 5 c = a + b Transfer(a, b, c) to = 'me' amount = 52 Refund(to, amount) return c
from boa.blockchain.vm.Neo.Action import RegisterAction from boa.blockchain.vm.Neo.Runtime import Log, Notify OnHello = RegisterAction('hello', 'name') def Main(operation, args): """ :param operation: str The name of the operation to perform :param args: list A list of arguments along with the operation :return: bytearray: The result of the operation """ if operation != None: if operation == 'hello': arg = args[0] Log('Sending notification') OnHello(arg) return True return False
from boa.blockchain.vm.Neo.Action import RegisterAction from boa.blockchain.vm.Neo.Runtime import Notify OnThing = RegisterAction('blah', 'bloop', 'bleep') def Main(): """ :return: """ ename = 'thing' arg1 = 2 arg2 = 4 OnThing(ename, arg1, arg2) return arg1
from boa.blockchain.vm.Neo.Runtime import Notify, GetTrigger, CheckWitness from boa.blockchain.vm.Neo.Action import RegisterAction from boa.blockchain.vm.Neo.TriggerType import Application, Verification from boa.blockchain.vm.Neo.TransactionType import InvocationTransaction from boa.blockchain.vm.Neo.Transaction import * from boa.blockchain.vm.System.ExecutionEngine import GetScriptContainer, GetExecutingScriptHash from boa.blockchain.vm.Neo.TriggerType import Application, Verification from boa.blockchain.vm.Neo.Output import GetScriptHash, GetValue, GetAssetId from boa.blockchain.vm.Neo.Storage import GetContext, Get, Put, Delete GAS_ASSET_ID = b'\xe7-(iy\xeel\xb1\xb7\xe6]\xfd\xdf\xb2\xe3\x84\x10\x0b\x8d\x14\x8ewX\xdeB\xe4\x16\x8bqy,`' OnSpend = RegisterAction('onSpend', 'to', 'amount', 'scripthash') def Main(num): receiver = GetExecutingScriptHash() tx = GetScriptContainer() references = tx.References reference = references[0] sender = GetScriptHash(reference) output_asset_id = GetAssetId(reference) if output_asset_id == GAS_ASSET_ID: print("good") for output in tx.Outputs: shash = GetScriptHash(output) value = GetValue(output) / 100000000
from boa.blockchain.vm.Neo.Blockchain import GetHeight from boa.blockchain.vm.Neo.Runtime import CheckWitness from boa.blockchain.vm.Neo.Action import RegisterAction from boa.blockchain.vm.Neo.Storage import Get, Put from boa.code.builtins import concat from nex.token import * from nex.txio import get_asset_attachments # OnInvalidKYCAddress = RegisterAction('invalid_registration', 'address') OnKYCRegister = RegisterAction('kyc_registration', 'address') OnTransfer = RegisterAction('transfer', 'addr_from', 'addr_to', 'amount') OnRefund = RegisterAction('refund', 'addr_to', 'amount') 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): for address in args: if len(address) == 20: kyc_storage_key = concat(KYC_KEY, address)
from boa.blockchain.vm.System.ExecutionEngine import GetExecutingScriptHash from boa.blockchain.vm.Neo.Runtime import GetTrigger, CheckWitness, Log, Notify from boa.blockchain.vm.Neo.TriggerType import Application, Verification from boa.blockchain.vm.Neo.Action import RegisterAction from cashflow.operations.operationscontroller import OperationsController from cashflow.payments.payment import Payment from cashflow.payments.withdrawalcontroller import WithdrawalController from cashflow.attachmentcontroller import getAttachedAssets, getOutputScriptHashes OnWithdrawalRequest = RegisterAction('withdrawal_request', 'uid', 'amount') OnClaimUnits = RegisterAction('claim_units', 'uid', 'units_count') SpentReleasedAssets = RegisterAction('spent_assets', 'address', 'amount') """ This smart-contract can be used to create payments between two partys. Every payment is only valid between a start and end date. Between those dates the receiver can withdraw the assets he worked for at any time. A job with a monthly salary is a TimeContract. Between the first and the last day of the month, an employee could withdraw his salary at any time. The withdrawal amount would be proportional to the time, that have passed. An insurance, which is paid annualy, would be valid from Jan. 1st to Dec 31th. If they choose to, a company could withdrawl a small amount of the fee at the end of every day. Contracts, which are depended on goods are UnitContracts. They are also only valid for a certain timerange, but a value is only created, when units are claimed. If the receiver is claiming some units, the owner has to authorize these units, before any assets can be withdrawn. Whenever a withdrawal is requested, an event is triggered, so the owner can deposit the requested amount. This way all payments are made just-in-time. If there is a trust issue in the beginning, one can set up an up-front contract. This contract needs to have the overall amount deposited with the initialization. """ def Main(operation_string_para, args): trigger = GetTrigger() if trigger == Verification: # all the hashes, which were found in the transaction outputs
INITIAL_FEE = 1 # MIN_TIME in seconds for the milestone to be in the future (1 day default) MIN_TIME = 86400 # MAX_TIME in seconds for the milestone to be in the future (365 days default) MAX_TIME = 31536000 # TIME_MARGIN margin for the above constants (1 hour default) TIME_MARGIN = 3600 # ------------------------------------------- # Events # ------------------------------------------- DispatchFeeUpdateEvent = RegisterAction('fee') DispatchMilestoneEvent = RegisterAction('milestone', 'milestone_key') DispatchReviewEvent = RegisterAction('review', 'milestone_key', 'review_score') DispatchTransferEvent = RegisterAction('transfer', 'from', 'to', 'amount') DispatchRefundEvent = RegisterAction('refund', 'milestone_key') DispatchDeleteMilestoneEvent = RegisterAction('delete', 'milestone_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 :type args: list :return: indicating the successful execution of the dApp
from boa.blockchain.vm.Neo.Action import RegisterAction call_event = RegisterAction('event', 'arg1', 'arg2') def Main(): m = 3 b = 8 call_event(m, b) return 3
from boa.blockchain.vm.Neo.App import RegisterAppCall from boa.blockchain.vm.Neo.Blockchain import GetHeight from boa.blockchain.vm.Neo.Action import RegisterAction from boa.blockchain.vm.Neo.Runtime import Notify,CheckWitness from boa.code.builtins import concat, sha1 from bsx.betting.bet import Bet, InitialiseBet, InitialiseNewBet from bsx.betting.user import User, GetUser from bsx.betting.queue import Queue, InitialiseQueue from bsx.common.utils import ValidateArgsLength, GetCurrentTimestamp from nex.common.storage import StorageAPI InvokeEventContract = RegisterAppCall("d21bee8a53177becfbf417cef93ec1e5aee1033a", "operation", "args", "sender") OnBetAdded = RegisterAction("bet_added", "bet_id", "user_id", "bet_details", "bet_index") OnBetCancelled = RegisterAction("bet_cancelled", "bet_id", "user_id", "bet_details") OnVoidBetClaimed = RegisterAction("void_bet_claimed", "bet_id", "user_id", "bet_details") OnBetClaimed = RegisterAction("bet_claimed", "bet_id" "user_id", "bet_details") class Exchange(): minimumBet = 10000000 minimumOdds = 101 feePoolID = b'fee_pool' def PlaceBet(self, args, sender): storage = StorageAPI()
from boa.blockchain.vm.Neo.Runtime import CheckWitness, Notify from boa.blockchain.vm.Neo.Action import RegisterAction from boa.code.builtins import concat from construct.platform.SmartTokenShare import SmartTokenShare, sts_get_attr, sts_create, sts_get, get_total_in_circulation from construct.common.StorageManager import StorageManager OnTransfer = RegisterAction('transfer', 'project_id', 'addr_from', 'addr_to', 'amount') OnApprove = RegisterAction('approve', 'project_id', 'addr_from', 'addr_to', 'amount') class SmartTokenShareHandler(): """ Based off the NEP5 Handler. The SmartTokenShareHandler handles the transfering of STS's """ def get_methods(self): methods = [ 'symbol', 'decimals', 'totalSupply', 'balanceOf', 'transfer', 'transferFrom', 'approve', 'allowance' ] return methods def handle_sts(self, operation, args): # project_id always first arg project_id = args[0] sts = sts_get(project_id)
from boa.blockchain.vm.Neo.Action import RegisterAction from boa.code.builtins import concat, sha1 from bsx.events.event import CreateEventID, StoreEventDetails from bsx.common.utils import ValidateArgsLength from nex.common.storage import StorageAPI OnNewEventAdded = RegisterAction("new_event_added", "event_id", "oracle_id", "event_details") OnNewEventConsensus = RegisterAction("new_event_consensus", "event_id", "oracle_id") OnNewEventConfirmed = RegisterAction("new_event_confirmed", "event_id", "oracle_id") OnEventOutcomeConsensus = RegisterAction("update_event_consensus", "event_id", "outcome", "oracle_id") OnEventOutcomeConfirmed = RegisterAction("update_event_confirmed", "event_id", "outcome", "oracle_id") class Oracle(): event_prefix = b'event/' oracle_prefix = b'oracle/' outcome_oracle_prefix = b'outcome_oracle/' outcome_count_prefix = b'outcome_count/' oracle_count_key = b'oracle/count' oracle_consensus_key = b'oracle/consensus' def AddEvent(self, args, oracleID):
def set_owner(context, to): previous = owner(context) if not previous: previous = to if not CheckWitness(previous): return "Only current owner can transfer ownership" Put(context, "owner", to) return True """ Plots """ OnPlotTransfer = RegisterAction('plot.transfer', 'owner', 'to', 'x', 'y') def plot_owner_key(x, y): return 'po:' + x + ':' + y def plot_sale_key(x, y): return 'ps:' + x + ':' + y def plot_owner(context, x, y): key = plot_owner_key(x, y) return Get(context, key)
from boa.blockchain.vm.Neo.Runtime import Notify from boa.blockchain.vm.Neo.Action import RegisterAction from boa.blockchain.vm.Neo.TriggerType import Application, Verification from boa.blockchain.vm.System.ExecutionEngine import GetScriptContainer, GetExecutingScriptHash from boa.blockchain.vm.Neo.Blockchain import GetHeight, GetHeader from boa.blockchain.vm.Neo.Runtime import GetTrigger, CheckWitness from boa.blockchain.vm.Neo.Output import GetScriptHash, GetValue, GetAssetId from boa.code.builtins import concat, list, range, take, substr SERIALIZED_NAME = 'LUCKYNEO' GAS_ASSET_ID = b'\xe7-(iy\xeel\xb1\xb7\xe6]\xfd\xdf\xb2\xe3\x84\x10\x0b\x8d\x14\x8ewX\xdeB\xe4\x16\x8bqy,`' OWNER = b'V6\x88\xb0%\xbe\xf9\xac \xfbJ\xd2bq\xe4\xf2\xc9w \x86' TWOWEEKS = 1209600000 OnWinner = RegisterAction('onWinner', 'to', 'amount', 'scripthash') OnRefund = RegisterAction('refund', 'to', 'amount') def Main(operation): print('entered main, getting trigger') trigger = GetTrigger() print('got trigger') print(trigger) # current bug with Verification() if trigger == b'\x00': print("doing verification!") owner_len = len(OWNER)
# ------------------------------------------- # DAPP SETTINGS # ------------------------------------------- OWNER = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' # Script hash of the token owner THRESHOLD = 50 # Threshold of relative sunshine duration percent on a given day # ------------------------------------------- # Events # ------------------------------------------- DispatchAgreementEvent = RegisterAction('agreement', 'agreement_key') DispatchResultNoticeEvent = RegisterAction('result-notice', 'agreement_key', 'weather_param', 'oracle_cost') DispatchClaimEvent = RegisterAction('pay-out', 'agreement_key') DispatchTransferEvent = RegisterAction('transfer', 'from', 'to', 'amount') DispatchRefundAllEvent = RegisterAction('refund-all', 'agreement_key') DispatchDeleteAgreementEvent = RegisterAction('delete', 'agreement_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 :type args: list
from boa.blockchain.vm.System.ExecutionEngine import GetScriptContainer, GetExecutingScriptHash from boa.blockchain.vm.Neo.Transaction import Transaction, GetReferences, GetOutputs, GetInputs, GetUnspentCoins from boa.blockchain.vm.Neo.Action import RegisterAction # THE CONSTRUCT - PLATFORMS from construct.platform.SmartTokenShare import SmartTokenShare, sts_get_attr, sts_create, sts_get, get_total_in_circulation, sts_total_available_amount from construct.platform.FundingStage import FundingStage, fs_get_attr, fs_create, fs_get, fs_contribute, fs_status, fs_can_exchange, fs_add_to_circulation, fs_calculate_can_exchange, get_in_circulation, fs_claim_contributions, fs_refund, fs_get_addr_balance, fs_set_addr_balance, fs_claim_system_fee, fs_calculate_system_fee, fs_available_amount from construct.platform.Milestone import Milestone, ms_create, ms_get, ms_get_attr, ms_update_progress, ms_get_progress from construct.platform.FundingRoadmap import FundingRoadmap, fr_list_append, fr_add_list, fr_get_list, fr_add_funding_stage, fr_get_funding_stages, fr_add_milestone, fr_get_milestones, fr_add_project_admin, fr_get_project_admins, fr_set_active_index, fr_get_active_index, fr_update_milestone_progress from construct.platform.KYC import KYC # THE CONSTRUCT - COMMON from construct.common.StorageManager import StorageManager from construct.common.Txio import Attachments, get_asset_attachments, get_asset_attachments_for_prev OnOperationInvoke = RegisterAction('operations_invoke', 'op_name') GAS_ASSET_ID = b'\xe7\x2d\x28\x69\x79\xee\x6c\xb1\xb7\xe6\x5d\xfd\xdf\xb2\xe3\x84\x10\x0b\x8d\x14\x8e\x77\x58\xde\x42\xe4\x16\x8b\x71\x79\x2c\x60' def Main(operation, args): """Entry point for the smart contract. Args: operation (str): UUID used as the first part of the key for Storage.Put(). args (str): UUID used as the second part of the key for Storage.Put(). Return: (bytearray): The result of the operation """
from boa.blockchain.vm.Neo.Action import RegisterAction from boa.blockchain.vm.Neo.Blockchain import GetHeight, GetHeader from boa.blockchain.vm.Neo.Runtime import Log, GetTrigger, CheckWitness from boa.blockchain.vm.Neo.Storage import Get, GetContext, Put, Delete from boa.blockchain.vm.Neo.TriggerType import Application, Verification from boa.blockchain.vm.System.ExecutionEngine import GetCallingScriptHash from boa.code.builtins import concat from utils.txio import get_asset_attachments from utils.promo import get_promo_storage_keys OWNER = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' OnTransfer = RegisterAction('transfer', 'addr_from', 'addr_to', 'amount') OnRefund = RegisterAction('refund', 'addr_to', 'amount') OnClaim = RegisterAction('claim', 'addr_to', 'amount') def Main(operation, args): trigger = GetTrigger() if trigger == Verification(): is_owner = CheckWitness(OWNER) if is_owner: return True return False elif trigger == Application(): # seller action if operation == 'create': if len(args) == 8:
from boa.blockchain.vm.Neo.Action import RegisterAction from boa.blockchain.vm.Neo.TriggerType import Application, Verification from boa.blockchain.vm.Neo.TransactionType import InvocationTransaction from boa.blockchain.vm.Neo.Transaction import * from boa.blockchain.vm.System.ExecutionEngine import GetScriptContainer, GetExecutingScriptHash from boa.blockchain.vm.Neo.TriggerType import Application, Verification from boa.blockchain.vm.Neo.Output import GetScriptHash, GetValue, GetAssetId from boa.blockchain.vm.Neo.Storage import GetContext, Get, Put, Delete OWNER = b'\x13\xff4\xcc\x10\x1cVs\x7fe\xc3\xb3\xd2\xf9iTHESK' 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' onDeposit = RegisterAction('deposit', 'account', 'amount') onWithdraw = RegisterAction('withdraw', 'account', 'amount') onWithdrawReconciled = RegisterAction('withdraw_reconcile', 'account', 'amount') def Main(args): print("RUNNING WITHDRAW TEST!!!!") trigger = GetTrigger() if trigger == Verification(): print("doing verification")
from boa.blockchain.vm.Neo.Blockchain import GetHeight, GetHeader from boa.blockchain.vm.Neo.Action import RegisterAction from boa.blockchain.vm.Neo.Runtime import Notify, CheckWitness from boa.code.builtins import concat, substr from nrve.token.nrvetoken import Token from nrve.common.storage import StorageAPI from nrve.common.txio import Attachments, get_asset_attachments from nrve.common.time import get_now OnTransfer = RegisterAction('transfer', 'from', 'to', 'amount') OnContribution = RegisterAction('contribution', 'from', 'neo', 'tokens') OnRefund = RegisterAction('refund', 'to', 'amount') OnPreSaleMint = RegisterAction('presale_mint', 'to', 'neo', 'tokens') OnKYCRegister = RegisterAction('kyc_registration', 'address') OnKYCDeregister = RegisterAction('kyc_deregistration', 'address') class Crowdsale(): kyc_key = b'kyc_ok' # February 9, 2018 @ 9:00:00 pm UTC presale_phase_key = b'r1' presale_individual_limit = 3000 presale_tokens_per_neo = 400 * 100000000 presale_minimum = 800 presale_token_limit = 20220000 * 100000000 # 50,550 NEO * 400 NRVE/NEO = 20.22m * 10^8 (decimals) # the number of blocks per day, assuming 23 seconds/block blocks_per_day = 3757 # 24 * 60 * 60 / 23
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with The ontology. If not, see <http://www.gnu.org/licenses/>. """ from boa.blockchain.vm.Neo.Runtime import GetTrigger, CheckWitness from boa.blockchain.vm.Neo.TriggerType import Application, Verification from lib.marketsLib import Markets from boa.blockchain.vm.Neo.Action import RegisterAction OWNER = b'' #register event CreateCategoricalEvent = RegisterAction('createCategoricalEvent', 'result') BetOnOutcome = RegisterAction('betOnOutcome', 'result') IsFinalOutcomeSet = RegisterAction('isFinalOutcomeSet', 'result') GetFinalOutcome = RegisterAction('getFinalOutcome', 'result') RedeemWinnings = RegisterAction('redeemWinnings', 'result') def Main(operation, args): """ :param operation: str The name of the operation to perform :param args: list A list of arguments along with the operation :return: bytearray: The result of the operation """ markets = Markets()
# Symbol of the Token OWNER = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' # Script hash of the contract owner DECIMALS = 8 # Number of decimal places TOTAL_SUPPLY = 123456789 # Total Supply of tokens in the system # ------------------------------------------- # Events # ------------------------------------------- DispatchTransferEvent = RegisterAction('transfer', 'from', 'to', 'amount') DispatchApproveEvent = RegisterAction('approval', 'owner', 'spender', 'value') [docs] 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
# ------------------------------------------- # Script hash of the contract owner. OWNER = b'#\xba\'\x03\xc52c\xe8\xd6\xe5"\xdc2 39\xdc\xd8\xee\xe9' # The URL of the associated URL shortener service. INITIAL_SHORTENER_URL = b'https://ledgr.link' # The key that will be used to store the shortener URL in the smart contract's storage. SHORTENER_URL_STORAGE_KEY = b'__shortenerurl__' # ------------------------------------------- # EVENTS # ------------------------------------------- DispatchNewURLEvent = RegisterAction('urladd', 'code', 'url') # ------------------------------------------- # CONTRACT METHODS # ------------------------------------------- def Main(operation, args): """ Main entrypoint for the smart contract. :param operation: the operation to be performed :param args: a list of arguments (which may be empty, but not absent) :type operation: str :type args: list :return: a boolean, a string or a byte array indicating the result of the execution of the SC :rtype: bool, string or bytearray
OWNER = b'\xaf\x12\xa8h{\x14\x94\x8b\xc4\xa0\x08\x12\x8aU\nci[\xc1\xa5' # Script hash of the contract owner DECIMALS = 8 # Number of decimal places TOTAL_SUPPLY = 500000000000000 # Total supply of tokens # ------------------------------------------- # Events # ------------------------------------------- OnTransfer = RegisterAction('transfer', 'from', 'to', 'amount') OnApprove = RegisterAction('approval', 'owner', 'spender', 'value') 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: an optional list of arguments :type args: list :return: indicating the successful execution of the smart contract
from boa.blockchain.vm.Neo.Blockchain import GetHeight from boa.blockchain.vm.Neo.Action import RegisterAction from boa.blockchain.vm.Neo.Runtime import Notify, CheckWitness from boa.code.builtins import concat, sha1 from bsx.common.utils import ValidateArgsLength, GetCurrentTimestamp from nex.common.storage import StorageAPI OnOracleAdded = RegisterAction("oracle_added", "oracle_id", "oracle_count") OnOracleRemoved = RegisterAction("oracle_removed", "oracle_id") class Admin(): OWNER = b'#\xba\'\x03\xc52c\xe8\xd6\xe5"\xdc2 39\xdc\xd8\xee\xe9' oracle_prefix = b'oracle/' oracle_count_key = b'oracle/count' oracle_consensus_key = b'oracle/consensus' admin_init_key = b'admin/initialised' def AddOracle(self, args): storage = StorageAPI() isValidOwner = self.ValidateOwner() if isValidOwner == False: return False isValidLength = ValidateArgsLength(args, 1) if isValidLength == False:
from boa.blockchain.vm.Neo.Runtime import CheckWitness, Notify from boa.blockchain.vm.Neo.Action import RegisterAction from boa.code.builtins import concat from ico.coin.onetoken import Token from ico.common.storage import StorageAPI OnTransfer = RegisterAction('transfer', 'from', 'to', 'amount') OnApprove = RegisterAction('approve', 'from', 'to', 'amount') class NEP5Handler(): def get_methods(self): m = [ 'name', 'symbol', 'decimals', 'totalSupply', 'balanceOf', 'transfer', 'transferFrom', 'approve', 'allowance' ] return m def handle_nep51(self, operation, args, token: Token): # these first 3 don't require get ctx if operation == 'name': return token.name elif operation == 'decimals': return token.decimals elif operation == 'symbol':
from boa.blockchain.vm.Neo.TransactionType import InvocationTransaction from boa.blockchain.vm.Neo.Transaction import * from boa.blockchain.vm.System.ExecutionEngine import GetScriptContainer, GetExecutingScriptHash, GetCallingScriptHash, GetEntryScriptHash from boa.blockchain.vm.Neo.Output import GetScriptHash, GetValue, GetAssetId from boa.blockchain.vm.Neo.Input import GetHash, GetIndex from boa.blockchain.vm.Neo.Storage import GetContext, Get, Put, Delete from boa.code.builtins import range, concat, list, print_var OWNER = b'\xaf\x12\xa8h{\x14\x94\x8b\xc4\xa0\x08\x12\x8aU\nci[\xc1\xa5' 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' onDeposit = RegisterAction('deposit', 'account', 'amount') onWithdrawRequestApproved = RegisterAction('withdrawApproved', 'account', 'vin_requests') def Main(operation, args): trigger = GetTrigger() if trigger == b'\x00': print("doing verification") # always allow owner to withdraw # this should be changed
from boa.blockchain.vm.Neo.Blockchain import GetHeight from boa.blockchain.vm.Neo.Action import RegisterAction from boa.blockchain.vm.Neo.Runtime import Notify, CheckWitness from boa.code.builtins import concat from nex.token.mytoken import Token from nex.common.storage import StorageAPI from nex.common.txio import Attachments, get_asset_attachments OnTransfer = RegisterAction('transfer', 'from', 'to', 'amount') OnRefund = RegisterAction('refund', 'to', 'amount') OnInvalidKYCAddress = RegisterAction('invalid_registration', 'address') OnKYCRegister = RegisterAction('kyc_registration', 'address') class Crowdsale(): kyc_key = b'kyc_ok' limited_round_key = b'r1' def kyc_register(self, args, token: Token): """ :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
from boa.blockchain.vm.System.ExecutionEngine import GetScriptContainer, GetExecutingScriptHash from boa.blockchain.vm.Neo.TriggerType import Application, Verification from boa.blockchain.vm.Neo.Output import GetScriptHash, GetValue, GetAssetId from boa.blockchain.vm.Neo.Storage import GetContext, Get, Put, Delete from boa.blockchain.vm.Neo.Blockchain import GetHeight Name = "NEO Robot Communication" Symbol = "NRC" Decimals = 0 InitialSupply = 50000000 MaximumSupply = 100000000 GenerationPerBlock = 100 FeePerBlock = 10 OnTransfer = RegisterAction('transfer', 'addr_from', 'addr_to', 'amount') ADMIN = b'031a6c6fbbdf02ca351745fa86b9ba5a9452d785ac4f7fc2b7548ca2a46c4fcf4a' def Main(method, args): if method == "test": return test() if method == "deploy": return Deploy() if not Grow(): return False if method == "name":