tx · Hk1QunLJEYNrAe7ZSQdb9EPHa25Y4VVhGYvHxLmZzzPw

3MwPF8FWd4fYohy6CXXB6wtjbRRvqFpxmdD:  -0.01000000 Waves

2023.08.19 19:30 [2717726] smart account 3MwPF8FWd4fYohy6CXXB6wtjbRRvqFpxmdD > SELF 0.00000000 Waves

{ "type": 13, "id": "Hk1QunLJEYNrAe7ZSQdb9EPHa25Y4VVhGYvHxLmZzzPw", "fee": 1000000, "feeAssetId": null, "timestamp": 1692462663374, "version": 2, "chainId": 84, "sender": "3MwPF8FWd4fYohy6CXXB6wtjbRRvqFpxmdD", "senderPublicKey": "G6PnkMn8MpXBkNwsQKMn1o1V7EKMgZyHCJRdFMQuouBC", "proofs": [ "4KxwQpqDVJBhXqqNhHEKv4RHVAryzeGyUDoieSu6Xf2namt52rC4MjY9denkc91RMyaNS8opq7yeJChXDB33VspT" ], "script": "base64:BgIJCAISABIDCgEBCAAQY29udHJhY3RGaWxlTmFtZQICcDEAA1NFUAIBXwAIa2Fzc2V0SWQCB0Fzc2V0SUQACWtuZXdUb2tlbgIFVG9rZW4BCmtleUFzc2V0SUQACQC5CQIJAMwIAgICJXMJAMwIAgIHYXNzZXRJRAUDbmlsBQNTRVABBWtleVR4AAkAuQkCCQDMCAICAiVzCQDMCAICCnB1cmNoYXNlOiAFA25pbAUDU0VQAQd3cmFwRXJyAQNtc2cJALkJAgkAzAgCBRBjb250cmFjdEZpbGVOYW1lCQDMCAICAToJAMwIAgUDbXNnBQNuaWwCAAEIdGhyb3dFcnIBA21zZwkAAgEJAQd3cmFwRXJyAQUDbXNnAgFpAQ10b2tlbklzc3VhbmNlAAQEbmFtZQIIUFJBQ1RJQ0UEC2Rlc2NyaXB0aW9uAgoxOjEwIHdhdmVzBAhxdWFudGl0eQCAreIEBAhkZWNpbWFscwAABAtpc3N1ZV90b2tlbgkAwggFBQRuYW1lBQtkZXNjcmlwdGlvbgUIcXVhbnRpdHkFCGRlY2ltYWxzBgQHYXNzZXRJZAkAuAg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entComplexity": 0 } View: original | compacted Prev: 9NpQXs6VfKqupPzdF43QYExgBqCdnFMLkmbqNd5s1okb Next: GkQThJFaL3X8ZPZuAczM7q7yL2UGiTD4JSRsEXb9VMae Diff:
OldNewDifferences
33 {-# CONTENT_TYPE DAPP #-}
44 let contractFileName = "p1"
55
6-let token_address = Address(base58'3MwPF8FWd4fYohy6CXXB6wtjbRRvqFpxmdD')
7-
8-let PRACTICE_token = base58'ETjui5BwgM7t2anpXm9A2pY3WzHpaxK8FWRPhw4Bo1GX'
9-
10-let SEP = " "
6+let SEP = "_"
117
128 let kassetId = "AssetID"
139
14-func keyMsg () = makeString(["%s", "Переданное сообщение: "], SEP)
10+let knewToken = "Token"
11+
12+func keyAssetID () = makeString(["%s", "assetID"], SEP)
1513
1614
17-func keyAssetID () = makeString(["%s", "assetID"], SEP)
15+func keyTx () = makeString(["%s", "purchase: "], SEP)
1816
1917
2018 func wrapErr (msg) = makeString([contractFileName, ":", msg], "")
2422
2523
2624 @Callable(i)
27-func message (msg) = {
28- let words = split(msg, SEP)
29- let wordCount = size(words)
30- let payment = i.payments[0]
31- let payment_amount = i.payments[0].amount
32- if ((payment_amount != wordCount))
33- then throwErr("Кол-во слов != кол-ву токенов")
34- else if ((PRACTICE_token == i.payments[0].assetId))
35- then throwErr("Платеж должен быть в PRACTICE")
36- else [StringEntry(keyMsg(), msg)]
25+func tokenIssuance () = {
26+ let name = "PRACTICE"
27+ let description = "1:10 waves"
28+ let quantity = 10000000
29+ let decimals = 0
30+ let issue_token = Issue(name, description, quantity, decimals, true)
31+ let assetId = calculateAssetId(issue_token)
32+[issue_token, BinaryEntry(kassetId, assetId), StringEntry(knewToken, issue_token.name)]
3733 }
3834
3935
40-@Verifier(tx)
41-func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
36+
37+@Callable(i)
38+func buyToken (quantity) = {
39+ let wavesOrErr = (i.payments[0].assetId == unit)
40+ let assetId = valueOrErrorMessage(getBinaryValue(this, kassetId), "id токена не найден")
41+ let paymentAmount = i.payments[0].amount
42+ let token_price = 10000000
43+ let amount_due = (token_price * quantity)
44+ let payment = match i.payments[0] {
45+ case p: AttachedPayment =>
46+ p
47+ case _ =>
48+ throw("Send exactly 0.1 WAVES")
49+ }
50+ if ((wavesOrErr != true))
51+ then throwErr("Платеж должен быть в WAVES")
52+ else if ((paymentAmount != amount_due))
53+ then throwErr("Неправильная сумма платежа")
54+ else [ScriptTransfer(i.caller, quantity, assetId), IntegerEntry(keyTx(), quantity)]
55+ }
56+
4257
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let contractFileName = "p1"
55
6-let token_address = Address(base58'3MwPF8FWd4fYohy6CXXB6wtjbRRvqFpxmdD')
7-
8-let PRACTICE_token = base58'ETjui5BwgM7t2anpXm9A2pY3WzHpaxK8FWRPhw4Bo1GX'
9-
10-let SEP = " "
6+let SEP = "_"
117
128 let kassetId = "AssetID"
139
14-func keyMsg () = makeString(["%s", "Переданное сообщение: "], SEP)
10+let knewToken = "Token"
11+
12+func keyAssetID () = makeString(["%s", "assetID"], SEP)
1513
1614
17-func keyAssetID () = makeString(["%s", "assetID"], SEP)
15+func keyTx () = makeString(["%s", "purchase: "], SEP)
1816
1917
2018 func wrapErr (msg) = makeString([contractFileName, ":", msg], "")
2119
2220
2321 func throwErr (msg) = throw(wrapErr(msg))
2422
2523
2624 @Callable(i)
27-func message (msg) = {
28- let words = split(msg, SEP)
29- let wordCount = size(words)
30- let payment = i.payments[0]
31- let payment_amount = i.payments[0].amount
32- if ((payment_amount != wordCount))
33- then throwErr("Кол-во слов != кол-ву токенов")
34- else if ((PRACTICE_token == i.payments[0].assetId))
35- then throwErr("Платеж должен быть в PRACTICE")
36- else [StringEntry(keyMsg(), msg)]
25+func tokenIssuance () = {
26+ let name = "PRACTICE"
27+ let description = "1:10 waves"
28+ let quantity = 10000000
29+ let decimals = 0
30+ let issue_token = Issue(name, description, quantity, decimals, true)
31+ let assetId = calculateAssetId(issue_token)
32+[issue_token, BinaryEntry(kassetId, assetId), StringEntry(knewToken, issue_token.name)]
3733 }
3834
3935
40-@Verifier(tx)
41-func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
36+
37+@Callable(i)
38+func buyToken (quantity) = {
39+ let wavesOrErr = (i.payments[0].assetId == unit)
40+ let assetId = valueOrErrorMessage(getBinaryValue(this, kassetId), "id токена не найден")
41+ let paymentAmount = i.payments[0].amount
42+ let token_price = 10000000
43+ let amount_due = (token_price * quantity)
44+ let payment = match i.payments[0] {
45+ case p: AttachedPayment =>
46+ p
47+ case _ =>
48+ throw("Send exactly 0.1 WAVES")
49+ }
50+ if ((wavesOrErr != true))
51+ then throwErr("Платеж должен быть в WAVES")
52+ else if ((paymentAmount != amount_due))
53+ then throwErr("Неправильная сумма платежа")
54+ else [ScriptTransfer(i.caller, quantity, assetId), IntegerEntry(keyTx(), quantity)]
55+ }
56+
4257

github/deemru/w8io/026f985 
48.25 ms