tx · 2BZdsFd9pwxdoZRmicybdcdhHtEbzzgRZLz3r8uQvcKH 3N9vjdhSVkpJcoa2UAVt4BWxTfZeV71cnan: -0.00400000 Waves 2022.08.10 15:27 [2178344] smart account 3N9vjdhSVkpJcoa2UAVt4BWxTfZeV71cnan > SELF 0.00000000 Waves
{ "type": 13, "id": "2BZdsFd9pwxdoZRmicybdcdhHtEbzzgRZLz3r8uQvcKH", "fee": 400000, "feeAssetId": null, "timestamp": 1660134511179, "version": 2, "chainId": 84, "sender": "3N9vjdhSVkpJcoa2UAVt4BWxTfZeV71cnan", "senderPublicKey": "DFMD24xWTnBgJR3y8Ls92YYq2Zmvx1rbEmDu18bd6nEe", "proofs": [ "5bvA2u52ahddarcRzD86VrEPxc5yQGSUWVZJjK765nPor3rZjseRHWocQtHN1mjpXoKaXNjhVebKjj8E9tvFQfX6" ], "script": "base64:AAIFAAAAAAAAACEIAhIGCgQICAEBEgUKAwEBARIDCgEBEgMKAQESABIAEgAAAAAPAAAAAA1rUHJvbW9Ub2tlbklkAgAAAA1wcm9tb19hc3NldElkAAAAAA9rZXlfdGlja2V0UHJpY2UCAAAADHRpY2tldF9wcmljZQAAAAATa2V5X3Rva2Vuc1BlclRpY2tldAIAAAARdG9rZW5zX3Blcl90aWNrZXQAAAAAGmtleV9wcmVzYWxlU3RhcnRzVGltZXN0YW1wAgAAABd0aW1lc3RhbXBfcHJlc2FsZV9zdGFydAAAAAAYa2V5X3ByZXNhbGVFbmRzVGltZXN0YW1wAgAAABV0aW1lc3RhbXBfcHJlc2FsZV9lbmQAAAAAGmtleV9yZXN1bHRzUmV2ZWFsVGltZXN0YW1wAgAAABh0aW1lc3RhbXBfcHJlc2FsZV9yZXN1bHQAAAAAEGtleV90b2tlblJlc2VydmUCAAAADnRva2Vuc19yZXNlcnZlAAAAABBrZXlfUHJpY2VBc3NldElkAgAAAA5wcmljZV9hc3NldF9pZAAAAAAKa1RvdGFsU29sZAIAAAAMdGlja2V0c19zb2xkAAAAAB1zd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NhbGxlcgUAAAANdGlja2V0c0Ftb3VudAUAAAADbmlsAAAAA2ludgEAAAATYnV5VGlja2V0V2l0aEZyZWV6ZQAAAAEAAAAKZnJlZXplVHlwZQUAAAADbmlsAAAAA2ludgEAAAAIZmluYWxpemUAAAAABQAAAANuaWwAAAADaW52AQAAAAVjbGFpbQAAAAAFAAAAA25pbAAAAANpbnYBAAAAC2NsYWltRnJvemVuAAAAAAUAAAADbmlsAAAAANCmuD0=", "height": 2178344, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7GekvKgUAcvxkb2rMxzca3yj31n2aGNLvhndPgPjpaza Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let kPromoTokenId = "promo_assetId" | |
5 | 5 | ||
6 | - | let key_ | |
6 | + | let key_ticketPrice = "ticket_price" | |
7 | 7 | ||
8 | - | let key_ | |
8 | + | let key_tokensPerTicket = "tokens_per_ticket" | |
9 | 9 | ||
10 | - | let key_ | |
10 | + | let key_presaleStartsTimestamp = "timestamp_presale_start" | |
11 | 11 | ||
12 | - | let key_ | |
12 | + | let key_presaleEndsTimestamp = "timestamp_presale_end" | |
13 | 13 | ||
14 | - | let key_ | |
14 | + | let key_resultsRevealTimestamp = "timestamp_presale_result" | |
15 | 15 | ||
16 | - | let | |
16 | + | let key_tokenReserve = "tokens_reserve" | |
17 | 17 | ||
18 | - | let | |
18 | + | let key_PriceAssetId = "price_asset_id" | |
19 | 19 | ||
20 | - | let | |
20 | + | let kTotalSold = "tickets_sold" | |
21 | 21 | ||
22 | - | let | |
22 | + | let suffix_TicketsPurchasedByUser = "_purchasedTotal" | |
23 | 23 | ||
24 | - | let | |
24 | + | let hashrateTokenId = getBinaryValue(this, kPromoTokenId) | |
25 | 25 | ||
26 | - | let | |
26 | + | let ticketPrice = valueOrErrorMessage(getInteger(this, key_ticketPrice), "") | |
27 | 27 | ||
28 | - | let | |
28 | + | let totalSold = valueOrElse(getInteger(this, kTotalSold), 0) | |
29 | 29 | ||
30 | - | let promoIssued = valueOrErrorMessage(getInteger(this, key_PromoIssued), "") | |
30 | + | func ticketsPurchased (user) = valueOrElse(getInteger(this, (toString(user) + suffix_TicketsPurchasedByUser)), 0) | |
31 | + | ||
32 | + | ||
33 | + | let priceAssetId = fromBase58String(valueOrErrorMessage(getString(this, key_PriceAssetId), "")) | |
31 | 34 | ||
32 | 35 | @Callable(inv) | |
33 | - | func init (hashrateAssetId,stakingDAppAddress,collectorAddress) = { | |
34 | - | let initAmountToBurn = 1 | |
35 | - | let issuePromo = Issue("REDSmb_Promo", "", initAmountToBurn, 8, true) | |
36 | - | let promoId = calculateAssetId(issuePromo) | |
37 | - | [StringEntry(key_HashrateTokenId, toBase58String(valueOrErrorMessage(assetInfo(fromBase58String(hashrateAssetId)), "").id)), StringEntry(key_StakingDApp, toString(valueOrErrorMessage(addressFromString(stakingDAppAddress), ""))), StringEntry(key_Collector, toString(valueOrErrorMessage(addressFromString(collectorAddress), ""))), IntegerEntry(key_Reserve, 0), IntegerEntry(key_PromoIssued, 0), issuePromo, Burn(promoId, initAmountToBurn), StringEntry(key_PromoTokenId, toBase58String(promoId)), IntegerEntry(key_Reserve, 0)] | |
36 | + | func initDApp (promoTokenIdStr,priceAssetIdStr,ticketPrice,equality) = { | |
37 | + | let pmt = if ((size(inv.payments) == 1)) | |
38 | + | then inv.payments[0] | |
39 | + | else throw("") | |
40 | + | let promoId = valueOrErrorMessage(assetInfo(valueOrErrorMessage(fromBase58String(promoTokenIdStr), "")), "").id | |
41 | + | let priceAsset = toBase58String(valueOrErrorMessage(assetInfo(fromBase58String(priceAssetIdStr)), "").id) | |
42 | + | let pr = if ((ticketPrice > 0)) | |
43 | + | then ticketPrice | |
44 | + | else throw("") | |
45 | + | let eq = if ((equality > 0)) | |
46 | + | then equality | |
47 | + | else throw("") | |
48 | + | [BinaryEntry(kPromoTokenId, promoId), StringEntry(key_PriceAssetId, priceAsset), IntegerEntry(key_ticketPrice, pr), IntegerEntry(key_tokensPerTicket, eq), IntegerEntry(key_tokenReserve, pmt.amount)] | |
38 | 49 | } | |
39 | 50 | ||
40 | 51 | ||
41 | 52 | ||
42 | 53 | @Callable(inv) | |
43 | - | func increaseReserve () = if ((inv.caller == this)) | |
44 | - | then throw() | |
45 | - | else if ((size(inv.payments) != 1)) | |
46 | - | then throw() | |
47 | - | else if ((inv.payments[0].assetId != hashrateTokenId)) | |
48 | - | then throw() | |
49 | - | else if ((0 >= inv.payments[0].amount)) | |
50 | - | then throw() | |
51 | - | else [IntegerEntry(key_Reserve, (reserve + inv.payments[0].amount))] | |
54 | + | func startSale (starts,ends,reveal) = [IntegerEntry(key_presaleStartsTimestamp, starts), IntegerEntry(key_presaleEndsTimestamp, ends), IntegerEntry(key_resultsRevealTimestamp, reveal)] | |
52 | 55 | ||
53 | 56 | ||
54 | 57 | ||
55 | 58 | @Callable(inv) | |
56 | - | func buyPromo (amountOfPromoTokens) = if ((size(inv.payments) != 1)) | |
57 | - | then throw("WAVES payment required") | |
58 | - | else if (isDefined(inv.payments[0].assetId)) | |
59 | - | then throw("Only WAVES payment accepted!") | |
60 | - | else if ((0 >= inv.payments[0].amount)) | |
61 | - | then throw("Payment amount must be positive") | |
62 | - | else if ((amountOfPromoTokens > (reserve - promoIssued))) | |
63 | - | then throw("") | |
64 | - | else [IntegerEntry(key_PromoIssued, (promoIssued + amountOfPromoTokens)), Reissue(promoTokenId, amountOfPromoTokens, true), ScriptTransfer(collector, inv.payments[0].amount, inv.payments[0].assetId), ScriptTransfer(inv.caller, amountOfPromoTokens, promoTokenId)] | |
65 | - | ||
66 | - | ||
67 | - | ||
68 | - | @Callable(inv) | |
69 | - | func redeemHashrateToken () = [Burn(valueOrErrorMessage(inv.payments[1].assetId, ""), inv.payments[1].amount), ScriptTransfer(collector, inv.payments[0].amount, inv.payments[0].assetId), ScriptTransfer(inv.caller, inv.payments[1].amount, hashrateTokenId)] | |
70 | - | ||
71 | - | ||
72 | - | ||
73 | - | @Callable(inv) | |
74 | - | func stakePromo (rewardType,timelock) = { | |
75 | - | let staking = invoke(stakingDApp, "stake", [rewardType, timelock], [inv.payments[0]]) | |
76 | - | if ((staking == staking)) | |
77 | - | then { | |
78 | - | let stakingKey = (toString(inv.caller) + "_staked") | |
79 | - | [IntegerEntry(stakingKey, (valueOrElse(getInteger(this, stakingKey), 0) + inv.payments[0].amount)), StringEntry(((toString(inv.caller) + "_") + toBase58String(inv.transactionId)), ((((toString(inv.payments[0].amount) + ",") + rewardType) + ",") + toString(timelock)))] | |
80 | - | } | |
81 | - | else throw("Strict value is not equal to itself.") | |
59 | + | func buyTickets (ticketsAmount) = { | |
60 | + | let pmt = inv.payments[0] | |
61 | + | if ((0 >= ticketsAmount)) | |
62 | + | then throw("amount must be positive") | |
63 | + | else if ((size(inv.payments) != 1)) | |
64 | + | then throw("1 payment required") | |
65 | + | else if ((pmt.assetId != priceAssetId)) | |
66 | + | then throw("only usdn") | |
67 | + | else if ((0 >= pmt.amount)) | |
68 | + | then throw("payment must be positive") | |
69 | + | else if (((ticketsAmount * ticketPrice) != pmt.amount)) | |
70 | + | then throw("payment amount must be accurate according to the price") | |
71 | + | else [IntegerEntry(kTotalSold, (totalSold + ticketsAmount)), IntegerEntry((toString(inv.originCaller) + suffix_TicketsPurchasedByUser), (ticketsPurchased(inv.originCaller) + ticketsAmount))] | |
82 | 72 | } | |
83 | 73 | ||
84 | 74 | ||
85 | 75 | ||
86 | 76 | @Callable(inv) | |
87 | - | func unstake () = nil | |
77 | + | func buyTicketWithFreeze (freezeType) = nil | |
78 | + | ||
79 | + | ||
80 | + | ||
81 | + | @Callable(inv) | |
82 | + | func finalize () = nil | |
83 | + | ||
84 | + | ||
85 | + | ||
86 | + | @Callable(inv) | |
87 | + | func claim () = nil | |
88 | + | ||
89 | + | ||
90 | + | ||
91 | + | @Callable(inv) | |
92 | + | func claimFrozen () = nil | |
88 | 93 | ||
89 | 94 |
github/deemru/w8io/026f985 51.43 ms ◑