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