Example #1
0
 def rewardfunds(self,daoid):
     sp.verify(self.data.addDAOdata[daoid].disputestatus==1)
     x=self.data.addDAOdata[daoid].winprojectid
     y=self.data.addDAOdata[daoid].winproposalid
     sendadd=self.data.addprojectdata[x].proowner
     count=self.data.addDAOdata[daoid].maxmember
     contribution=self.data.addDAOdata[daoid].min_contribution
     sp.for x in sp.range(0,count):
         sendfunds=contribution+contribution
Example #2
0
class SimpleLottery(sp.Contract):
    def __init__(self):
        self.init(limit = 5, ticketToAddress = sp.map(tkey = sp.TNat, tvalue = sp.TAddress), id = 0, previousWinners = sp.list(t = sp.TAddress))
    
    @sp.entry_point
    def buyTicket(self, qty):
        sp.verify(sp.tez(qty) == sp.amount)
        
        change = sp.local('change', sp.tez(0))
        canBuy = sp.local('canBuy', qty)
        remaining = sp.as_nat(self.data.limit - self.data.id)
        sp.if qty > remaining:
            canBuy.value = remaining
            change.value = sp.tez(sp.as_nat(qty - remaining))
        
        sp.for i in sp.range(1, canBuy.value + 1):
            self.data.ticketToAddress[self.data.id] = sp.sender
            self.data.id += 1
Example #3
0
 def resetLottery(self):
     self.data.id = 0
     sp.for i in sp.range(0, self.data.limit):
         del self.data.ticketToAddress[i]
Example #4
0
 def iter_on_operator(metaset, ledger, upd, action):
     if assume_consecutive_token_ids:
         sp.for tok in sp.range(0, metaset + 1):
             user = Ledger_key.make(upd.owner, tok)
             action(ledger[user], upd.operator)
Example #5
0
 def all_tokens(self):
     if self.config.assume_consecutive_token_ids:
         sp.result(sp.range(0, self.data.all_tokens))
     else:
         sp.result(self.data.all_tokens.elements())
Example #6
0
 def factorial(self, x):
     self.data.value = 1
     sp.for y in sp.range(1, x + 1):
         self.data.value *= y
Example #7
0
 def factorial(self, params):
     self.data.storedValue = 1
     sp.for x in sp.range(1, params.op+1):
         self.data.storedValue *= x