tx · AQL6ZWm8ZTqQTt3n821DVYkPYMooH4y8bcSDs6GoA3vD 3NADYuG3G91PrmsrRqQfyeDCf2Pi53UV5id: -0.01400000 Waves 2021.05.19 02:52 [1531803] smart account 3NADYuG3G91PrmsrRqQfyeDCf2Pi53UV5id > SELF 0.00000000 Waves
{ "type": 13, "id": "AQL6ZWm8ZTqQTt3n821DVYkPYMooH4y8bcSDs6GoA3vD", "fee": 1400000, "feeAssetId": null, "timestamp": 1621381970168, "version": 2, "chainId": 84, "sender": "3NADYuG3G91PrmsrRqQfyeDCf2Pi53UV5id", "senderPublicKey": "8agr5kfwDL7NLuMetvciXCcd9TcDKZhRwYZPPTAShaCC", "proofs": [ "56uXaBpLwDhoLRSwvnqHyLNU9wqUKqGSNWPr7tkjU8REpsooj2McFZi6vUcX5wag4DV4Ju6TUHqtUeUgMPMQkUEd" ], "script": "base64:AAIEAAAAAAAAABkIAhIFCgMICAgSBAoCAQESABIAEgQKAggIAAAACgAAAAAPa2V5RXhjaGFuZ2VSYXRlAgAAAA1leGNoYW5nZV9yYXRlAAAAAB1rZXlFeGNoYW5nZVJhdGVTY2FsZURlbGltaXRlcgIAAAAdZXhjaGFuZ2VfcmF0ZV9zY2FsZV9kZWxpbWl0ZXIAAAAADWtleUNvbW1pc3Npb24CAAAACmNvbW1pc3Npb24AAAAAG2tleUNvbW1pc3Npb25TY2FsZURlbGltaXRlcgIAAAAaY29tbWlzc2lvbl9zY2FsZV9kZWxpbWl0ZXIAAAAABFVTRE4BAAAAIOSwcsQaO/7w9gk22WMNYWxRgCp4LSxG18pSVz66uVShAAAAAAZVV09STEQBAAAAIFw5P18I1L4GAMZe978MAfIh+BM42SxhQKId1T0PstxdAAAAAAdhc3NldElkBQAAAARVU0ROAAAAAApjb21taXNzaW9uAAAAAAAAAHUwAAAAABhjb21taXNzaW9uU2NhbGVEZWxpbWl0ZXIAAAAAAAAPQkAAAAAACm1ha2VORlRmZWUAAAAAAAAHoSAAAAAFAAAAAWkBAAAAB21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bnRBZGRyZXNzBQAAAA5hbW91bnRDYXNoYmFjawUAAAAGVVdPUkxECQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcgUAAAAOYW1vdW50Q2FzaGJhY2sFAAAABlVXT1JMRAUAAAADbmlsAAAAAOdVtZA=", "height": 1531803, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 91CsdXtbeQHMztpYnZhp3XaYbogqXCxGR12YEtKmDh9o Next: 89nPJifB1jkjboZ8cuba1sms6BbasLPyJzpcXrDHsRqS Diff:
Old | New | Differences | |
---|---|---|---|
19 | 19 | ||
20 | 20 | let commissionScaleDelimiter = 1000000 | |
21 | 21 | ||
22 | + | let makeNFTfee = 500000 | |
23 | + | ||
24 | + | @Callable(i) | |
25 | + | func makeNFT (name,description,productId) = { | |
26 | + | let $t0863938 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
27 | + | let pmtAmount = $t0863938._1 | |
28 | + | let pmtAssetId = $t0863938._2 | |
29 | + | if ((pmtAssetId != assetId)) | |
30 | + | then throw("Asset must be USDN only") | |
31 | + | else if ((makeNFTfee > pmtAmount)) | |
32 | + | then throw(("Fee for make NFT token is " + toString(makeNFTfee))) | |
33 | + | else if (isDefined(getString(this, productId))) | |
34 | + | then throw("NFT for this productId is already issued.") | |
35 | + | else { | |
36 | + | let newAsset = Issue(name, (((description + "[") + productId) + "]"), 1, 0, true, unit, 0) | |
37 | + | let newAssetId = calculateAssetId(newAsset) | |
38 | + | [newAsset, StringEntry(productId, toBase58String(newAssetId))] | |
39 | + | } | |
40 | + | } | |
41 | + | ||
42 | + | ||
43 | + | ||
22 | 44 | @Callable(i) | |
23 | 45 | func setParams (exchangeRate,exchangeRateScaleDelimiter) = if ((i.caller != this)) | |
24 | 46 | then throw("Only the DApp itself can call this function") | |
28 | 50 | ||
29 | 51 | @Callable(i) | |
30 | 52 | func buyUWORLD () = { | |
31 | - | let $ | |
32 | - | let pmtAmount = $ | |
33 | - | let pmtAssetId = $ | |
53 | + | let $t019282003 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
54 | + | let pmtAmount = $t019282003._1 | |
55 | + | let pmtAssetId = $t019282003._2 | |
34 | 56 | if ((pmtAssetId != assetId)) | |
35 | 57 | then throw("Asset must be USDN only") | |
36 | 58 | else { | |
47 | 69 | ||
48 | 70 | @Callable(i) | |
49 | 71 | func sellUWORLD () = { | |
50 | - | let $ | |
51 | - | let pmtAmount = $ | |
52 | - | let pmtAssetId = $ | |
72 | + | let $t026612736 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
73 | + | let pmtAmount = $t026612736._1 | |
74 | + | let pmtAssetId = $t026612736._2 | |
53 | 75 | if ((pmtAssetId != UWORLD)) | |
54 | 76 | then throw("Asset must be UWORLD only") | |
55 | 77 | else { | |
65 | 87 | ||
66 | 88 | ||
67 | 89 | @Callable(i) | |
68 | - | func makePayment (recipient) = { | |
90 | + | func makePayment (recipient,productId) = { | |
69 | 91 | let recipientAddress = addressFromStringValue(recipient) | |
70 | - | let $ | |
71 | - | let pmtAmount = $ | |
72 | - | let pmtAssetId = $ | |
92 | + | let $t034913566 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
93 | + | let pmtAmount = $t034913566._1 | |
94 | + | let pmtAssetId = $t034913566._2 | |
73 | 95 | if ((pmtAssetId != assetId)) | |
74 | 96 | then throw("Asset must be USDN only") | |
75 | 97 | else { | |
76 | 98 | let amountCommission = fraction(pmtAmount, commission, commissionScaleDelimiter) | |
77 | 99 | let amountWithoutCommission = (pmtAmount - amountCommission) | |
78 | 100 | let amountCashback = fraction(pmtAmount, 10, 100) | |
79 | - | [ScriptTransfer(recipientAddress, amountWithoutCommission, assetId), ScriptTransfer(recipientAddress, amountCashback, UWORLD), ScriptTransfer(i.caller, amountCashback, UWORLD)] | |
101 | + | let NFTassetId = fromBase58String(getStringValue(this, productId)) | |
102 | + | if (isDefined(NFTassetId)) | |
103 | + | then [ScriptTransfer(recipientAddress, amountWithoutCommission, assetId), ScriptTransfer(recipientAddress, amountCashback, UWORLD), ScriptTransfer(i.caller, amountCashback, UWORLD), ScriptTransfer(i.caller, 1, NFTassetId)] | |
104 | + | else [ScriptTransfer(recipientAddress, amountWithoutCommission, assetId), ScriptTransfer(recipientAddress, amountCashback, UWORLD), ScriptTransfer(i.caller, amountCashback, UWORLD)] | |
80 | 105 | } | |
81 | 106 | } | |
82 | 107 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let keyExchangeRate = "exchange_rate" | |
5 | 5 | ||
6 | 6 | let keyExchangeRateScaleDelimiter = "exchange_rate_scale_delimiter" | |
7 | 7 | ||
8 | 8 | let keyCommission = "commission" | |
9 | 9 | ||
10 | 10 | let keyCommissionScaleDelimiter = "commission_scale_delimiter" | |
11 | 11 | ||
12 | 12 | let USDN = base58'GPi1Q6QVgUmuomtThbim81hBYBEUWyf5BVmE4Tnd3sNg' | |
13 | 13 | ||
14 | 14 | let UWORLD = base58'7D191wpwpSs4WanizHWgiRhAYhCGkmpop4h3NzUQreig' | |
15 | 15 | ||
16 | 16 | let assetId = USDN | |
17 | 17 | ||
18 | 18 | let commission = 30000 | |
19 | 19 | ||
20 | 20 | let commissionScaleDelimiter = 1000000 | |
21 | 21 | ||
22 | + | let makeNFTfee = 500000 | |
23 | + | ||
24 | + | @Callable(i) | |
25 | + | func makeNFT (name,description,productId) = { | |
26 | + | let $t0863938 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
27 | + | let pmtAmount = $t0863938._1 | |
28 | + | let pmtAssetId = $t0863938._2 | |
29 | + | if ((pmtAssetId != assetId)) | |
30 | + | then throw("Asset must be USDN only") | |
31 | + | else if ((makeNFTfee > pmtAmount)) | |
32 | + | then throw(("Fee for make NFT token is " + toString(makeNFTfee))) | |
33 | + | else if (isDefined(getString(this, productId))) | |
34 | + | then throw("NFT for this productId is already issued.") | |
35 | + | else { | |
36 | + | let newAsset = Issue(name, (((description + "[") + productId) + "]"), 1, 0, true, unit, 0) | |
37 | + | let newAssetId = calculateAssetId(newAsset) | |
38 | + | [newAsset, StringEntry(productId, toBase58String(newAssetId))] | |
39 | + | } | |
40 | + | } | |
41 | + | ||
42 | + | ||
43 | + | ||
22 | 44 | @Callable(i) | |
23 | 45 | func setParams (exchangeRate,exchangeRateScaleDelimiter) = if ((i.caller != this)) | |
24 | 46 | then throw("Only the DApp itself can call this function") | |
25 | 47 | else [IntegerEntry(keyExchangeRate, exchangeRate), IntegerEntry(keyExchangeRateScaleDelimiter, exchangeRateScaleDelimiter), IntegerEntry(keyCommission, commission), IntegerEntry(keyCommissionScaleDelimiter, commissionScaleDelimiter)] | |
26 | 48 | ||
27 | 49 | ||
28 | 50 | ||
29 | 51 | @Callable(i) | |
30 | 52 | func buyUWORLD () = { | |
31 | - | let $ | |
32 | - | let pmtAmount = $ | |
33 | - | let pmtAssetId = $ | |
53 | + | let $t019282003 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
54 | + | let pmtAmount = $t019282003._1 | |
55 | + | let pmtAssetId = $t019282003._2 | |
34 | 56 | if ((pmtAssetId != assetId)) | |
35 | 57 | then throw("Asset must be USDN only") | |
36 | 58 | else { | |
37 | 59 | let exchangeRate = getIntegerValue(this, keyExchangeRate) | |
38 | 60 | let exchangeRateScaleDelimiter = getIntegerValue(this, keyExchangeRateScaleDelimiter) | |
39 | 61 | let amountToPay = fraction(pmtAmount, exchangeRateScaleDelimiter, exchangeRate) | |
40 | 62 | let amountCommission = fraction(amountToPay, commission, commissionScaleDelimiter) | |
41 | 63 | let amountWithoutCommission = (amountToPay - amountCommission) | |
42 | 64 | [ScriptTransfer(i.caller, amountWithoutCommission, UWORLD)] | |
43 | 65 | } | |
44 | 66 | } | |
45 | 67 | ||
46 | 68 | ||
47 | 69 | ||
48 | 70 | @Callable(i) | |
49 | 71 | func sellUWORLD () = { | |
50 | - | let $ | |
51 | - | let pmtAmount = $ | |
52 | - | let pmtAssetId = $ | |
72 | + | let $t026612736 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
73 | + | let pmtAmount = $t026612736._1 | |
74 | + | let pmtAssetId = $t026612736._2 | |
53 | 75 | if ((pmtAssetId != UWORLD)) | |
54 | 76 | then throw("Asset must be UWORLD only") | |
55 | 77 | else { | |
56 | 78 | let exchangeRate = getIntegerValue(this, keyExchangeRate) | |
57 | 79 | let exchangeRateScaleDelimiter = getIntegerValue(this, keyExchangeRateScaleDelimiter) | |
58 | 80 | let amountToPay = fraction(pmtAmount, exchangeRate, exchangeRateScaleDelimiter) | |
59 | 81 | let amountCommission = fraction(amountToPay, commission, commissionScaleDelimiter) | |
60 | 82 | let amountWithoutCommission = (amountToPay - amountCommission) | |
61 | 83 | [ScriptTransfer(i.caller, amountWithoutCommission, USDN)] | |
62 | 84 | } | |
63 | 85 | } | |
64 | 86 | ||
65 | 87 | ||
66 | 88 | ||
67 | 89 | @Callable(i) | |
68 | - | func makePayment (recipient) = { | |
90 | + | func makePayment (recipient,productId) = { | |
69 | 91 | let recipientAddress = addressFromStringValue(recipient) | |
70 | - | let $ | |
71 | - | let pmtAmount = $ | |
72 | - | let pmtAssetId = $ | |
92 | + | let $t034913566 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
93 | + | let pmtAmount = $t034913566._1 | |
94 | + | let pmtAssetId = $t034913566._2 | |
73 | 95 | if ((pmtAssetId != assetId)) | |
74 | 96 | then throw("Asset must be USDN only") | |
75 | 97 | else { | |
76 | 98 | let amountCommission = fraction(pmtAmount, commission, commissionScaleDelimiter) | |
77 | 99 | let amountWithoutCommission = (pmtAmount - amountCommission) | |
78 | 100 | let amountCashback = fraction(pmtAmount, 10, 100) | |
79 | - | [ScriptTransfer(recipientAddress, amountWithoutCommission, assetId), ScriptTransfer(recipientAddress, amountCashback, UWORLD), ScriptTransfer(i.caller, amountCashback, UWORLD)] | |
101 | + | let NFTassetId = fromBase58String(getStringValue(this, productId)) | |
102 | + | if (isDefined(NFTassetId)) | |
103 | + | then [ScriptTransfer(recipientAddress, amountWithoutCommission, assetId), ScriptTransfer(recipientAddress, amountCashback, UWORLD), ScriptTransfer(i.caller, amountCashback, UWORLD), ScriptTransfer(i.caller, 1, NFTassetId)] | |
104 | + | else [ScriptTransfer(recipientAddress, amountWithoutCommission, assetId), ScriptTransfer(recipientAddress, amountCashback, UWORLD), ScriptTransfer(i.caller, amountCashback, UWORLD)] | |
80 | 105 | } | |
81 | 106 | } | |
82 | 107 | ||
83 | 108 |
github/deemru/w8io/026f985 41.40 ms ◑