def invoke_a(addr): sc_a = RegisterAppCall(addr, 'op', 'args') res = sc_a('test', 'sth') Notify(res)
def invoke_a1(addr): sc_a = RegisterAppCall(addr, 'op', 'args') res = sc_a('test1', '') return res
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.App import RegisterAppCall OWNER = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' # mainnet #MCT_SCRIPTHASH = b'?\xbc`|\x12\xc2\x87642$\xa4\xb4\xd8\xf5\x13\xa5\xc2|\xa8' # privatenet MCT_SCRIPTHASH = b'\x8dKL\x14V4\x17\xc6\x91\x91\xe0\x8b\xe0\xb8m\xdc\xb4\xbc\x86\xc1' # mainnet #MCTContract = RegisterAppCall('a87cc2a513f5d8b4a42432343687c2127c60bc3f', 'operation', 'args') # privatenet MCTContract = RegisterAppCall('c186bcb4dc6db8e08be09191c6173456144c4b8d', 'operation', 'args') def Main(operation, args): trigger = GetTrigger() if trigger == Verification(): if CheckWitness(OWNER): return True return False elif trigger == Application(): if operation == 'hello':
from boa.interop.Neo.App import RegisterAppCall CalculatorContract = RegisterAppCall('9e17cd49e4a198e8825b775bd685a4d0818a757', 'operation', 'a', 'b') def Main(operation, a, b): result = CalculatorContract(operation, a, b) return result
This code demonstrates atomic NEP-5 token swap on Neo using NEP-5+ tokens """ 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.App import RegisterAppCall from boa.builtins import concat OWNER = b'\xdc\xcbK\xc2\xeb4TV\xe0\x15\xf9>|\t\xad\xfa\xcc\xea\x1ez' minimum_hold = 10000 * 100000000 # contract must maintain this amount of tokens for staked storage TOKEN1 = b'\xe7\xb12\xb9\x95\xf4=\xbb\xdd\xd2\xa3&\x8a\x04\xa2\xae\x08\x1e\xff\x9a' TOKEN2 = b'\xe7\xb2\x06\xc4\xc6#\xebGKQ\x03>M\x10\xdd\x94\xc9\xcb\xd9\x81' Token1Contract = RegisterAppCall('9aff1e08aea2048a26a3d2ddbb3df495b932b1e7', 'operation', 'args') Token2Contract = RegisterAppCall('81d9cbc994dd104d3e03514b47eb23c6c406b2e7', 'operation', 'args') def Main(operation, args): trigger = GetTrigger() if trigger == Verification(): if CheckWitness(OWNER): return True return False elif trigger == Application(): if operation == 'setExchangeRate': if not CheckWitness(OWNER):
from boa.interop.Neo.App import RegisterAppCall from boa.interop.System.Runtime import Log # Here "749a701ae89c0dbdab9b4b660ba84ee478004219" should your OPE4 contract hash, pls note it's not reversed version OEP4Contract = RegisterAppCall('749a701ae89c0dbdab9b4b660ba84ee478004219', 'operation', 'args') def Main(operation, args): if operation == "transfer": if len(args) != 3: Log("len(args)!=3 ") return False return CallNep5Contract("transfer", args) # Here you can define the method name "Name" to anything you want if operation == "Name": # This "name" below should be consistent with your OEP4Contract methods return OEP4Contract("name", 0) # Here you can define the method name "BalanceOf" to anything you want if operation == "BalanceOf": # This "balanceOf" below should be consistent with your OEP4Contract methods return OEP4Contract("balanceOf", args) def CallNep5Contract(operation, params): return OEP4Contract(operation, params)
from boa.interop.Neo.App import RegisterAppCall CalculatorContract = RegisterAppCall( '86d58778c8d29e03182f38369f0d97782d303cc0', 'operation', 'a', 'b') def Main(operation, a, b): result = CalculatorContract(operation, a, b) return result
from boa.interop.Neo.App import RegisterAppCall from boa.interop.System.Runtime import Log YouLeContract = RegisterAppCall('731aa306346c486c126d86b17624f8e970b097ee', 'operation', 'a', 'b', 'c') def Main(operation, args): if operation == "CallNep5Contract": Log("1111111111") if len(args) != 4: return False from_acct = args[0] to_acct = args[1] value = args[2] hash_a = args[3] return CallNep5Contract(from_acct, to_acct, value, hash_a) def CallNep5Contract(from_acct, to_acct, value, contractHash): Log("222222222") res = YouLeContract("transfer", from_acct, to_acct, value) if res != "\x01": raise Exception() return True
""" from boa.interop.Neo.Runtime import GetTrigger, CheckWitness from boa.interop.Neo.TriggerType import Application, Verification from boa.interop.System.ExecutionEngine import GetExecutingScriptHash, GetCallingScriptHash, GetScriptContainer from boa.interop.Neo.Transaction import GetHash from boa.interop.Neo.App import RegisterAppCall from boa.builtins import concat # address that will stake the tokens for the contract to have storage OWNER = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' # TestNet - CTX MCT_HASH = b'\xe7\xb12\xb9\x95\xf4=\xbb\xdd\xd2\xa3&\x8a\x04\xa2\xae\x08\x1e\xff\x9a' MCTContract = RegisterAppCall('9aff1e08aea2048a26a3d2ddbb3df495b932b1e7', 'operation', 'args') # MaiNet - MCT #MCT_HASH = b'?\xbc`|\x12\xc2\x87642$\xa4\xb4\xd8\xf5\x13\xa5\xc2|\xa8' #MCTContract = RegisterAppCall('a87cc2a513f5d8b4a42432343687c2127c60bc3f', 'operation', 'args') OnError = RegisterAction('error', 'message') def Main(operation, args): trigger = GetTrigger() if trigger == Verification(): return False # no withdrawals allowed, even by contract owner
Deployment in neo-python: import contract mct-dapp-template.py 0710 05 False False wallet tkn_send MCT {from address} {dApp contract address} {minimum stake} """ 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.App import RegisterAppCall OWNER = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' MCT_SCRIPTHASH = b'?\xbc`|\x12\xc2\x87642$\xa4\xb4\xd8\xf5\x13\xa5\xc2|\xa8' MCTContract = RegisterAppCall('a87cc2a513f5d8b4a42432343687c2127c60bc3f', 'operation', 'args') def Main(operation, args): trigger = GetTrigger() if trigger == Verification(): if CheckWitness(OWNER): return True return False elif trigger == Application(): if operation == 'hello': print('hello world!')
from boa.interop.Neo.App import RegisterAppCall OEP4Contract = RegisterAppCall('1b86175747d0c1490d5b48b20b10584e378ed947', 'operation', 'args') def Main(operation, args): if operation == 'transfer': return OEP4Contract('transfer', args) return False
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(): if operation == 'currentKing':
from boa.interop.Neo.App import RegisterAppCall contractA = RegisterAppCall('a5813ff2d3825caf2a52396f23b9e50a9aa7a7c8', 'operation', 'args') def Main(operation, args): contractA('testtesttest', [12345])
from boa.interop.Neo.App import RegisterAppCall CalculatorContract = RegisterAppCall( b'W\xa7\x18\x08MZh\xbdu\xb7%\x88\x8e\x19J\x9e\xd4|\xe1\xe3\xaa', 'operation', 'a', 'b') def Main(operation, a, b): result = CalculatorContract(operation, a, b) return result
class MCTManager: ''' Wrapper for the MCT Storage Calls ''' ctx = RegisterAppCall('c186bcb4dc6db8e08be09191c6173456144c4b8d', 'operation', 'args') def get(self, key): return self.ctx('Get', [key]) def delete(self, key): return self.ctx('Delete', [key]) def put(self, key, value): return self.ctx('Put', [key, value]) def transfer(self, my_hash, amount): return self.ctx('transfer', [my_hash, OWNER, amount]) def deserialize(self, data): # neo-boa bug, Something is require here for some reason... print('deserialize_bytearray') collection_length_length = substr(data, 0, 1) collection_len = substr(data, 1, collection_length_length) new_collection = list(length=collection_len) offset = 1 + collection_length_length newdata = data[offset:] for i in range(0, collection_len): datalen_len = substr(newdata, 0, 1) data_len = substr(newdata, 1, datalen_len) start = 1 + datalen_len stop = start + data_len data = substr(newdata, start, data_len) new_collection[i] = data newdata = newdata[stop:] return new_collection def serialize_array(self, items): item_length = self.serialize_length_item(items) output = item_length for item in items: itemlen = self.serialize_length_item(item) output = concat(output, itemlen) output = concat(output, item) return output def serialize_length_item(self, item: list): thing_len = len(item) if thing_len <= 255: byte_len = b'\x02' else: byte_len = b'\x04' out = concat(byte_len, thing_len) return out