SC Arguments: [Name:SC_ACTION Type:uint64 Value:'0' Name:SC_ID Type:hash Value:'b6530e5d8aa55c550120701f8616001f12ab49106d3b5d7fbd4c43fa186801fa' Name:code Type:string Value:'//Copyright (c) 2024, dero1qyfyqe9v72xaha3dgz0m7qxa0vyru3g9vc9vwagtdpluewmv0mx26qqsavvj9. All rights reserved. Licence scid: e0ca740d8df8a4c30be9c32e32fddf797a383042f6ddc87f636343711fcbe8e5
//Parts of the InitializePrivate() & Update() code are Copyright (c) 2022, Civilware. All rights reserved. Licence scid: e973273da5efbdd852ee5a0535e28c45d49f0bff7e9ce4d00544b5d95015bd89
Function Pay_7_LOTTO__Game_777_Rounds() Uint64
1 IF EXISTS("7game") THEN GOTO 10
4 STORE("7game", 1)
5 STORE("7ticket_price", 7)
6 STORE("7max_tickets", 777) // rounds
7 STORE("7lottery_pool", 0)
8 STORE("7ticket_count", 0)
10 DIM scid_LOTTO_tokens, current_player as String
20 DIM ticket_price, max_tickets, lottery_pool, ticket_count as Uint64
30 LET scid_LOTTO_tokens = scid()
40 LET ticket_price = LOAD("7ticket_price") * 100000
50 IF ASSETVALUE(scid_LOTTO_tokens) != ticket_price THEN GOTO 999
60 LET lottery_pool = LOAD("7lottery_pool")
70 LET lottery_pool = lottery_pool + ticket_price
90 LET ticket_count = LOAD("7ticket_count")
100 LET ticket_count = ticket_count + 1
110 LET max_tickets = LOAD("7max_tickets")
120 LET current_player = ITOA(ticket_count) + "_player_" + ITOA(ticket_price / 100000) + "_" + ITOA(max_tickets)
130 IF ticket_count < max_tickets THEN GOTO 400
170 DIM rand, winner_pool as Uint64
180 DIM winner, winner_address as String
190 LET rand = RANDOM(max_tickets) + 1
200 LET winner = ITOA(rand) + "_player_" + ITOA(ticket_price / 100000) + "_" + ITOA(max_tickets)
205 IF rand == max_tickets THEN GOTO 206 ELSE GOTO 210
206 LET winner_address = ADDRESS_STRING(SIGNER())
207 GOTO 220
210 LET winner_address = ADDRESS_STRING(LOAD(winner))
220 STORE("winner_address", winner_address)
230 STORE("rand", rand)
240 IF EXISTS(winner_address) THEN GOTO 245 ELSE GOTO 250
245 LET winner_pool = LOAD(winner_address) + lottery_pool
246 GOTO 255
250 LET winner_pool = lottery_pool
255 STORE(winner_address, winner_pool)
260 DIM i as Uint64
261 DIM player_to_remove as String
265 LET i = 1
266 IF i == max_tickets THEN GOTO 280
270 LET player_to_remove = ITOA(i) + "_player_" + ITOA(ticket_price / 100000) + "_" + ITOA(max_tickets)
275 DELETE(player_to_remove)
280 LET i = i + 1
285 IF i < max_tickets THEN GOTO 270
300 LET ticket_count = 0
310 LET lottery_pool = 0
390 GOTO 500
400 STORE(current_player, SIGNER())
500 STORE("7ticket_count", ticket_count)
510 STORE("7lottery_pool", lottery_pool)
800 RETURN 0
999 RETURN 1
End Function
Function Pay_77_LOTTO__Game_77_Rounds() Uint64
1 IF EXISTS("77game") THEN GOTO 10
4 STORE("77game", 1)
5 STORE("77ticket_price", 77)
6 STORE("77max_tickets", 77) // rounds
7 STORE("77lottery_pool", 0)
8 STORE("77ticket_count", 0)
10 DIM scid_LOTTO_tokens, current_player as String
20 DIM ticket_price, max_tickets, lottery_pool, ticket_count as Uint64
30 LET scid_LOTTO_tokens = scid()
40 LET ticket_price = LOAD("77ticket_price") * 100000
50 IF ASSETVALUE(scid_LOTTO_tokens) != ticket_price THEN GOTO 999
60 LET lottery_pool = LOAD("77lottery_pool")
70 LET lottery_pool = lottery_pool + ticket_price
90 LET ticket_count = LOAD("77ticket_count")
100 LET ticket_count = ticket_count + 1
110 LET max_tickets = LOAD("77max_tickets")
120 LET current_player = ITOA(ticket_count) + "_player_" + ITOA(ticket_price / 100000) + "_" + ITOA(max_tickets)
130 IF ticket_count < max_tickets THEN GOTO 400
170 DIM rand, winner_pool as Uint64
180 DIM winner, winner_address as String
190 LET rand = RANDOM(max_tickets) + 1
200 LET winner = ITOA(rand) + "_player_" + ITOA(ticket_price / 100000) + "_" + ITOA(max_tickets)
205 IF rand == max_tickets THEN GOTO 206 ELSE GOTO 210
206 LET winner_address = ADDRESS_STRING(SIGNER())
207 GOTO 220
210 LET winner_address = ADDRESS_STRING(LOAD(winner))
220 STORE("winner_address", winner_address)
230 STORE("rand", rand)
240 IF EXISTS(winner_address) THEN GOTO 245 ELSE GOTO 250
245 LET winner_pool = LOAD(winner_address) + lottery_pool
246 GOTO 255
250 LET winner_pool = lottery_pool
255 STORE(winner_address, winner_pool)
260 DIM i as Uint64
261 DIM player_to_remove as String
265 LET i = 1
266 IF i == max_tickets THEN GOTO 280
270 LET player_to_remove = ITOA(i) + "_player_" + ITOA(ticket_price / 100000) + "_" + ITOA(max_tickets)
275 DELETE(player_to_remove)
280 LET i = i + 1
285 IF i < max_tickets THEN GOTO 270
300 LET ticket_count = 0
310 LET lottery_pool = 0
390 GOTO 500
400 STORE(current_player, SIGNER())
500 STORE("77ticket_count", ticket_count)
510 STORE("77lottery_pool", lottery_pool)
800 RETURN 0
999 RETURN 1
End Function
Function Pay_777_LOTTO__Game_7_Rounds() Uint64
1 IF EXISTS("777game") THEN GOTO 10
4 STORE("777game", 1)
5 STORE("777ticket_price", 777)
6 STORE("777max_tickets", 7) // rounds
7 STORE("777lottery_pool", 0)
8 STORE("777ticket_count", 0)
10 DIM scid_LOTTO_tokens, current_player as String
20 DIM ticket_price, max_tickets, lottery_pool, ticket_count as Uint64
30 LET scid_LOTTO_tokens = scid()
40 LET ticket_price = LOAD("777ticket_price") * 100000
50 IF ASSETVALUE(scid_LOTTO_tokens) != ticket_price THEN GOTO 999
60 LET lottery_pool = LOAD("777lottery_pool")
70 LET lottery_pool = lottery_pool + ticket_price
90 LET ticket_count = LOAD("777ticket_count")
100 LET ticket_count = ticket_count + 1
110 LET max_tickets = LOAD("777max_tickets")
120 LET current_player = ITOA(ticket_count) + "_player_" + ITOA(ticket_price / 100000) + "_" + ITOA(max_tickets)
130 IF ticket_count < max_tickets THEN GOTO 400
170 DIM rand, winner_pool as Uint64
180 DIM winner, winner_address as String
190 LET rand = RANDOM(max_tickets) + 1
200 LET winner = ITOA(rand) + "_player_" + ITOA(ticket_price / 100000) + "_" + ITOA(max_tickets)
205 IF rand == max_tickets THEN GOTO 206 ELSE GOTO 210
206 LET winner_address = ADDRESS_STRING(SIGNER())
207 GOTO 220
210 LET winner_address = ADDRESS_STRING(LOAD(winner))
220 STORE("winner_address", winner_address)
230 STORE("rand", rand)
240 IF EXISTS(winner_address) THEN GOTO 245 ELSE GOTO 250
245 LET winner_pool = LOAD(winner_address) + lottery_pool
246 GOTO 255
250 LET winner_pool = lottery_pool
255 STORE(winner_address, winner_pool)
260 DIM i as Uint64
261 DIM player_to_remove as String
265 LET i = 1
266 IF i == max_tickets THEN GOTO 280
270 LET player_to_remove = ITOA(i) + "_player_" + ITOA(ticket_price / 100000) + "_" + ITOA(max_tickets)
275 DELETE(player_to_remove)
280 LET i = i + 1
285 IF i < max_tickets THEN GOTO 270
300 LET ticket_count = 0
310 LET lottery_pool = 0
390 GOTO 500
400 STORE(current_player, SIGNER())
500 STORE("777ticket_count", ticket_count)
510 STORE("777lottery_pool", lottery_pool)
800 RETURN 0
999 RETURN 1
End Function
Function MintLOTTO() Uint64
10 DIM minted, waitingtime, adr_count as Uint64
15 LET adr_count = LOAD("adr_count")
20 LET waitingtime = LOAD("waitingtime")
30 LET minted = LOAD("minted")
50 DIM onemint, rand as Uint64
60 LET rand = RANDOM(3) +1
70 IF rand == 1 THEN GOTO 100
80 IF rand == 2 THEN GOTO 110
90 IF rand == 3 THEN GOTO 120
100 LET onemint = 7 * 100000
101 GOTO 130
110 LET onemint = 77 * 100000
111 GOTO 130
120 LET onemint = 777 * 100000
130 DIM lastMintBlock, blocktime as Uint64
135 IF minted + onemint > LOAD("totalsupply") THEN GOTO 999
140 IF EXISTS(ADDRESS_STRING(SIGNER()) + "_lmb") THEN GOTO 200
150 LET lastMintBlock = 0
151 STORE("adr" + adr_count, SIGNER())
152 STORE("adr_count", adr_count + 1)
160 GOTO 250
200 LET lastMintBlock = LOAD(ADDRESS_STRING(SIGNER()) + "_lmb")
250 STORE(ADDRESS_STRING(SIGNER()) + "_lmb", BLOCK_TIMESTAMP())
300 DIM result as Uint64
310 LET result = BLOCK_TIMESTAMP() - lastMintBlock
320 IF result < waitingtime THEN GOTO 999
400 SEND_ASSET_TO_ADDRESS(SIGNER(), onemint, SCID())
410 STORE("minted", minted + onemint)
420 STORE(ADDRESS_STRING(SIGNER()) + "_lmb", BLOCK_TIMESTAMP())
500 IF minted + onemint == LOAD("totalsupply") THEN GOTO 510 ELSE GOTO 990
510 rmg()
990 RETURN 0
999 RETURN 1
End Function
Function rmg() Uint64
10 DIM i, adr_count as Uint64
20 DIM adr_to_remove, adr_to_remove2 as String
25 LET adr_count = LOAD("adr_count")
30 LET i = 0
40 IF i == adr_count THEN GOTO 190
50 LET adr_to_remove = "adr" + ITOA(i)
55 LET adr_to_remove2 = ADDRESS_STRING(LOAD("adr" + ITOA(i)))
60 DELETE(adr_to_remove)
64 LET adr_to_remove2 = adr_to_remove2 + "_lmb"
65 DELETE(adr_to_remove2)
70 LET i = i + 1
80 IF i < adr_count THEN GOTO 50
190 RETURN 0
200 RETURN 1
End Function
Function Withdraw_My_LOTTO_balance() Uint64
10 IF EXISTS(ADDRESS_STRING(SIGNER())) THEN GOTO 20 ELSE GOTO 999
20 DIM balance_to_withdraw, withdrawal_fee, amount_artificerAddr, amount_owner, amount_signer as Uint64
30 DIM scid_LOTTO_tokens, owner, artificerAddr as String
60 LET scid_LOTTO_tokens = scid()
70 LET balance_to_withdraw = LOAD(ADDRESS_STRING(SIGNER()))
80 LET withdrawal_fee = LOAD("withdrawal_fee")
90 LET owner = LOAD("owner")
95 LET artificerAddr = LOAD("artificerAddr")
96 IF SIGNER() == owner THEN GOTO 98
97 IF SIGNER() == artificerAddr THEN GOTO 98 ELSE GOTO 100
98 LET amount_signer = balance_to_withdraw
99 GOTO 160
100 LET amount_signer = balance_to_withdraw - balance_to_withdraw * withdrawal_fee / 100
110 LET amount_owner = balance_to_withdraw * withdrawal_fee / 100 * 95 / 100
120 LET amount_artificerAddr = balance_to_withdraw * withdrawal_fee / 100 * 5 / 100
125 IF EXISTS(ADDRESS_STRING(owner)) THEN GOTO 126 ELSE GOTO 130
126 LET amount_owner = amount_owner + LOAD(ADDRESS_STRING(owner))
130 STORE(ADDRESS_STRING(owner), amount_owner)
135 IF EXISTS(ADDRESS_STRING(artificerAddr)) THEN GOTO 136 ELSE GOTO 140
136 LET amount_artificerAddr = amount_artificerAddr + LOAD(ADDRESS_STRING(artificerAddr))
140 STORE(ADDRESS_STRING(artificerAddr), amount_artificerAddr)
160 SEND_ASSET_TO_ADDRESS(SIGNER(), amount_signer, scid_LOTTO_tokens)
170 DELETE(ADDRESS_STRING(SIGNER()))
900 RETURN 0
999 RETURN 1
End Function
Function UpdateCode(code String) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 UPDATE_SC_CODE(code)
40 RETURN 0
End Function
' Name:entrypoint Type:string Value:'UpdateCode'] |