tx · DDq4tiUU1CZLkcPDSBJ5XN4FyH56cbEF8wSUxJTKeLCy 3MwPF8FWd4fYohy6CXXB6wtjbRRvqFpxmdD: -0.01000000 Waves 2023.08.19 19:36 [2717733] smart account 3MwPF8FWd4fYohy6CXXB6wtjbRRvqFpxmdD > SELF 0.00000000 Waves
{ "type": 13, "id": "DDq4tiUU1CZLkcPDSBJ5XN4FyH56cbEF8wSUxJTKeLCy", "fee": 1000000, "feeAssetId": null, "timestamp": 1692463038722, "version": 2, "chainId": 84, "sender": "3MwPF8FWd4fYohy6CXXB6wtjbRRvqFpxmdD", "senderPublicKey": "G6PnkMn8MpXBkNwsQKMn1o1V7EKMgZyHCJRdFMQuouBC", "proofs": [ "5p1GTjoeKyx5CfmBGrkqWhNcaV3iXzG7PCcqW4KEZvZZGJRizaj67f6MmidKW86TQcv19p8xs3DQ6qLYe4GA9EyP" ], "script": "base64:BgIJCAISABIDCgEBCAAQY29udHJhY3RGaWxlTmFtZQICcDEAA1NFUAIBXwAIa2Fzc2V0SWQCB0Fzc2V0SUQACWtuZXdUb2tlbgIFVG9rZW4BCmtleUFzc2V0SUQACQC5CQIJAMwIAgICJXMJAMwIAgIHYXNzZXRJRAUDbmlsBQNTRVABBWtleVR4AAkAuQkCCQDMCAICAiVzCQDMCAICCnB1cmNoYXNlOiAFA25pbAUDU0VQAQd3cmFwRXJyAQNtc2cJALkJAgkAzAgCBRBjb250cmFjdEZpbGVOYW1lCQDMCAICAToJAMwIAgUDbXNnBQNuaWwCAAEIdGhyb3dFcnIBA21zZwkAAgEJAQd3cmFwRXJyAQUDbXNnAgFpAQ10b2tlbklzc3VhbmNlAAQEbmFtZQIIUFJBQ1RJQ0UEC2Rlc2NyaXB0aW9uAgoxOjEwIHdhdmVzBAhxdWFudGl0eQCAreIEBAhkZWNpbWFscwAABAtpc3N1ZV90b2tlbgkAwggFBQRuYW1lBQtkZXNjcmlwdGlvbgUIcXVhbnRpdHkFCGRlY2ltYWxzBgQHYXNzZXRJZAk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ded", "spentComplexity": 0 } View: original | compacted Prev: GkQThJFaL3X8ZPZuAczM7q7yL2UGiTD4JSRsEXb9VMae Next: 4qW4EZjVvZmwS2fuaprXHbBViP5zFwTP95baF4q3FAa2 Diff:
Old | New | Differences | |
---|---|---|---|
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let contractFileName = "p1" | |
5 | 5 | ||
6 | - | let token_address = Address(base58'3MwPF8FWd4fYohy6CXXB6wtjbRRvqFpxmdD') | |
7 | - | ||
8 | - | let PRACTICE_token = base58'BQE3kUrRJ2nEzsXVeuB1KGBdyRhCHa3fRtSkyTsCJwa1' | |
9 | - | ||
10 | - | let SEP = " " | |
6 | + | let SEP = "_" | |
11 | 7 | ||
12 | 8 | let kassetId = "AssetID" | |
13 | 9 | ||
14 | - | func keyMsg () = makeString(["%s", "Переданное сообщение: "], SEP) | |
10 | + | let knewToken = "Token" | |
11 | + | ||
12 | + | func keyAssetID () = makeString(["%s", "assetID"], SEP) | |
15 | 13 | ||
16 | 14 | ||
17 | - | func | |
15 | + | func keyTx () = makeString(["%s", "purchase: "], SEP) | |
18 | 16 | ||
19 | 17 | ||
20 | 18 | func wrapErr (msg) = makeString([contractFileName, ":", msg], "") | |
24 | 22 | ||
25 | 23 | ||
26 | 24 | @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)] | |
37 | 33 | } | |
38 | 34 | ||
39 | 35 | ||
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 | + | ||
42 | 57 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let contractFileName = "p1" | |
5 | 5 | ||
6 | - | let token_address = Address(base58'3MwPF8FWd4fYohy6CXXB6wtjbRRvqFpxmdD') | |
7 | - | ||
8 | - | let PRACTICE_token = base58'BQE3kUrRJ2nEzsXVeuB1KGBdyRhCHa3fRtSkyTsCJwa1' | |
9 | - | ||
10 | - | let SEP = " " | |
6 | + | let SEP = "_" | |
11 | 7 | ||
12 | 8 | let kassetId = "AssetID" | |
13 | 9 | ||
14 | - | func keyMsg () = makeString(["%s", "Переданное сообщение: "], SEP) | |
10 | + | let knewToken = "Token" | |
11 | + | ||
12 | + | func keyAssetID () = makeString(["%s", "assetID"], SEP) | |
15 | 13 | ||
16 | 14 | ||
17 | - | func | |
15 | + | func keyTx () = makeString(["%s", "purchase: "], SEP) | |
18 | 16 | ||
19 | 17 | ||
20 | 18 | func wrapErr (msg) = makeString([contractFileName, ":", msg], "") | |
21 | 19 | ||
22 | 20 | ||
23 | 21 | func throwErr (msg) = throw(wrapErr(msg)) | |
24 | 22 | ||
25 | 23 | ||
26 | 24 | @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)] | |
37 | 33 | } | |
38 | 34 | ||
39 | 35 | ||
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 | + | ||
42 | 57 |
github/deemru/w8io/026f985 41.65 ms ◑