tx · BXPhdbCAZxfFsenrNqT3rnxGkEVyWTkhNJsTQeKDA6Ri 3MwPF8FWd4fYohy6CXXB6wtjbRRvqFpxmdD: -0.01000000 Waves 2023.07.30 13:59 [2688513] smart account 3MwPF8FWd4fYohy6CXXB6wtjbRRvqFpxmdD > SELF 0.00000000 Waves
{ "type": 13, "id": "BXPhdbCAZxfFsenrNqT3rnxGkEVyWTkhNJsTQeKDA6Ri", "fee": 1000000, "feeAssetId": null, "timestamp": 1690714790165, "version": 2, "chainId": 84, "sender": "3MwPF8FWd4fYohy6CXXB6wtjbRRvqFpxmdD", "senderPublicKey": "G6PnkMn8MpXBkNwsQKMn1o1V7EKMgZyHCJRdFMQuouBC", "proofs": [ "5s9EHL5ec9Gaaut7pSqmuDgvnVRvHstMkz4M5RgE7BeCqVqjLQUryZ4jTMy9L9EVLQE1nbNCPQ1R8WHLEJanK3ST" ], "script": "base64:BgIHCAISAwoBCAgAEGNvbnRyYWN0RmlsZU5hbWUCAnAxAA10b2tlbl9hZGRyZXNzCQEHQWRkcmVzcwEBGgFUUevquKc82yLj6POP0d8MGx4c9yM7LkYsAANTRVACASAACGthc3NldElkAgdBc3NldElEAQZrZXlNc2cACQC5CQIJAMwIAgICJXMJAMwIAgIp0J/QtdGA0LXQtNCw0L3QvdC+0LUg0YHQvtC+0LHRidC10L3QuNC1OiAFA25pbAUDU0VQAQprZXlBc3NldElEAAkAuQkCCQDMCAICAiVzCQDMCAICB2Fzc2V0SUQFA25pbAUDU0VQAQd3cmFwRXJyAQNtc2cJALkJAgkAzAgCBRBjb250cmFjdEZpbGVOYW1lCQDMCAICAToJAMwIAgUDbXNnBQNuaWwCAAEIdGhyb3dFcnIBA21zZwkAAgEJAQd3cmFwRXJyAQUDbXNnAQFpAQdtZXNzYWdlAQNtc2cEBXdvcmRzCQC1CQIFA21zZwUDU0VQBAl3b3JkQ291bnQJAJADAQUFd29yZHMECmdldEFzc2V0SUQJARFAZXh0ck5hdGl2ZSgxMDUzKQIFDXRva2VuX2FkZHJlc3MFCGthc3NldElkBA90b0J5dGVzX2Fzc2V0SUQJAJsDAQUKZ2V0QXNzZXRJRAQHcGF5bWVudAkAkQMCCAUBaQhwYXltZW50cwAABA5wYXltZW50X2Ftb3VudAgJAJEDAggFAWkIcGF5bWVudHMAAAZhbW91bnQDCQECIT0CBQ5wYXltZW50X2Ftb3VudAUJd29yZENvdW50CQEIdGhyb3dFcnIBAjLQmtC+0Lst0LLQviDRgdC70L7QsiAhPSDQutC+0Lst0LLRgyDRgtC+0LrQtdC90L7QsgMJAAACBQ90b0J5dGVzX2Fzc2V0SUQICQCRAwIIBQFpCHBheW1lbnRzAAAHYXNzZXRJZAkBCHRocm93RXJyAQJ20J/Qu9Cw0YLQtdC2INC00L7Qu9C20LXQvSDQsdGL0YLRjCDRgNCw0LLQtdC9INC60L7Qu9C40YfQtdGB0YLQstGDINGB0LvQvtCyINCyINC/0LXRgNC10LTQsNC90L3QvtC8INGB0L7QvtCx0YnQtdC90LjQuAkAzAgCCQELU3RyaW5nRW50cnkCBQhrYXNzZXRJZAUKZ2V0QXNzZXRJRAkAzAgCCQELU3RyaW5nRW50cnkCCQEGa2V5TXNnAAUDbXNnBQNuaWwBAnR4AQZ2ZXJpZnkACQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V5FwT44Q==", "height": 2688513, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3BXHgiykf8xd4NT2DwiZ8jjdxbgmsDCXKaXQH8TcvzGF Next: h8bsiUMBLDnnbG3YpUVZi6cfnoorRfzvaZVG9jzg8J7 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 SEP = " " | |
7 | 9 | ||
8 | 10 | let kassetId = "AssetID" | |
9 | 11 | ||
10 | - | let knewToken = "Token" | |
12 | + | func keyMsg () = makeString(["%s", "Переданное сообщение: "], SEP) | |
13 | + | ||
11 | 14 | ||
12 | 15 | func keyAssetID () = makeString(["%s", "assetID"], SEP) | |
13 | 16 | ||
19 | 22 | ||
20 | 23 | ||
21 | 24 | @Callable(i) | |
22 | - | func tokenIssuance () = { | |
23 | - | let name = "PRACTICE" | |
24 | - | let description = "1:10 waves" | |
25 | - | let quantity = 10000000 | |
26 | - | let decimals = 3 | |
27 | - | let issue_token = Issue(name, description, quantity, decimals, true) | |
28 | - | let assetId = calculateAssetId(issue_token) | |
29 | - | [issue_token, BinaryEntry(kassetId, assetId), StringEntry(knewToken, issue_token.name)] | |
25 | + | func message (msg) = { | |
26 | + | let words = split(msg, SEP) | |
27 | + | let wordCount = size(words) | |
28 | + | let getAssetID = getStringValue(token_address, kassetId) | |
29 | + | let toBytes_assetID = toBytes(getAssetID) | |
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 ((toBytes_assetID == i.payments[0].assetId)) | |
35 | + | then throwErr("Платеж должен быть равен количеству слов в переданном сообщении") | |
36 | + | else [StringEntry(kassetId, getAssetID), StringEntry(keyMsg(), msg)] | |
30 | 37 | } | |
31 | 38 | ||
32 | 39 | ||
33 | - | ||
34 | - | @Callable(i) | |
35 | - | func buyToken (quantity) = { | |
36 | - | let wavesOrErr = (i.payments[0].assetId == unit) | |
37 | - | let assetId = valueOrErrorMessage(getBinaryValue(this, kassetId), "id токена не найден") | |
38 | - | let paymentAmount = i.payments[0].amount | |
39 | - | let token_price = 10000 | |
40 | - | let amount_due = (token_price * quantity) | |
41 | - | let payment = match i.payments[0] { | |
42 | - | case p: AttachedPayment => | |
43 | - | p | |
44 | - | case _ => | |
45 | - | throw("Send exactly 0.1 WAVES") | |
46 | - | } | |
47 | - | if ((wavesOrErr != true)) | |
48 | - | then throwErr("Платеж должен быть в WAVES") | |
49 | - | else if ((paymentAmount != amount_due)) | |
50 | - | then throwErr("Неправильная сумма платежа") | |
51 | - | else [ScriptTransfer(i.caller, quantity, assetId)] | |
52 | - | } | |
53 | - | ||
40 | + | @Verifier(tx) | |
41 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
54 | 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 SEP = " " | |
7 | 9 | ||
8 | 10 | let kassetId = "AssetID" | |
9 | 11 | ||
10 | - | let knewToken = "Token" | |
12 | + | func keyMsg () = makeString(["%s", "Переданное сообщение: "], SEP) | |
13 | + | ||
11 | 14 | ||
12 | 15 | func keyAssetID () = makeString(["%s", "assetID"], SEP) | |
13 | 16 | ||
14 | 17 | ||
15 | 18 | func wrapErr (msg) = makeString([contractFileName, ":", msg], "") | |
16 | 19 | ||
17 | 20 | ||
18 | 21 | func throwErr (msg) = throw(wrapErr(msg)) | |
19 | 22 | ||
20 | 23 | ||
21 | 24 | @Callable(i) | |
22 | - | func tokenIssuance () = { | |
23 | - | let name = "PRACTICE" | |
24 | - | let description = "1:10 waves" | |
25 | - | let quantity = 10000000 | |
26 | - | let decimals = 3 | |
27 | - | let issue_token = Issue(name, description, quantity, decimals, true) | |
28 | - | let assetId = calculateAssetId(issue_token) | |
29 | - | [issue_token, BinaryEntry(kassetId, assetId), StringEntry(knewToken, issue_token.name)] | |
25 | + | func message (msg) = { | |
26 | + | let words = split(msg, SEP) | |
27 | + | let wordCount = size(words) | |
28 | + | let getAssetID = getStringValue(token_address, kassetId) | |
29 | + | let toBytes_assetID = toBytes(getAssetID) | |
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 ((toBytes_assetID == i.payments[0].assetId)) | |
35 | + | then throwErr("Платеж должен быть равен количеству слов в переданном сообщении") | |
36 | + | else [StringEntry(kassetId, getAssetID), StringEntry(keyMsg(), msg)] | |
30 | 37 | } | |
31 | 38 | ||
32 | 39 | ||
33 | - | ||
34 | - | @Callable(i) | |
35 | - | func buyToken (quantity) = { | |
36 | - | let wavesOrErr = (i.payments[0].assetId == unit) | |
37 | - | let assetId = valueOrErrorMessage(getBinaryValue(this, kassetId), "id токена не найден") | |
38 | - | let paymentAmount = i.payments[0].amount | |
39 | - | let token_price = 10000 | |
40 | - | let amount_due = (token_price * quantity) | |
41 | - | let payment = match i.payments[0] { | |
42 | - | case p: AttachedPayment => | |
43 | - | p | |
44 | - | case _ => | |
45 | - | throw("Send exactly 0.1 WAVES") | |
46 | - | } | |
47 | - | if ((wavesOrErr != true)) | |
48 | - | then throwErr("Платеж должен быть в WAVES") | |
49 | - | else if ((paymentAmount != amount_due)) | |
50 | - | then throwErr("Неправильная сумма платежа") | |
51 | - | else [ScriptTransfer(i.caller, quantity, assetId)] | |
52 | - | } | |
53 | - | ||
40 | + | @Verifier(tx) | |
41 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
54 | 42 |
github/deemru/w8io/026f985 31.62 ms ◑