tx · 9kJZuAoCok521fLPgN5UG18zWDaX8FqQhkRmtvZWf845 3N8Cko4wa6ewdnPRXybzTMDpnhuYREfkps7: -0.00200000 Waves 2023.09.30 19:41 [2778416] smart account 3N8Cko4wa6ewdnPRXybzTMDpnhuYREfkps7 > SELF 0.00000000 Waves
{ "type": 13, "id": "9kJZuAoCok521fLPgN5UG18zWDaX8FqQhkRmtvZWf845", "fee": 200000, "feeAssetId": null, "timestamp": 1696092102088, "version": 2, "chainId": 84, "sender": "3N8Cko4wa6ewdnPRXybzTMDpnhuYREfkps7", "senderPublicKey": "4oVxBvsmoAhMaT1WhgSLcKFKX1NzwYxDaR89cAdGRGky", "proofs": [ "2NRD2RhfKvtGVkwsFHt6DFoDM1eNmXLJFcLfpt6EVDwUC7H2EKyNeRHNqdjhRLkD14QnfKG5ZuTTXBnjsvo3u7Lh" ], "script": "base64:BgIOCAISABIECgIIARIAEgAGAAVjaGFpbgkAyQECCQDKAQIIBQR0aGlzBWJ5dGVzAAEAAQALdXNkdEFzc2V0SWQEByRtYXRjaDAFBWNoYWluAwkAAAIBAVcFByRtYXRjaDABIITaerIIAz9O0bvKju6Lk7zJgt0LXfoHlqjUI/moD/+5AwkAAAIBAVQFByRtYXRjaDABIFWx2J9yh4Lv5eNbjawFq2XemkOhLxa7BfMat4el8cUYCQACAQINVW5rbm93biBjaGFpbgEKZml4ZWRQb2ludAIDdmFsCGRlY2ltYWxzBAZ0ZW5Qb3cJAGwGAAoAAAUIZGVjaW1hbHMAAAAABQRET1dOBAdsb3dQYXJ0CQCkAwEJAGoCBQN2YWwFBnRlblBvdwQGemVyb2VzCQCwAgIJAKQDAQUGdGVuUG93CQBkAgABCQCxAgEFB2xvd1BhcnQJAKwCAgkArAICCQCsAgIJAKQDAQkAaQIFA3ZhbAUGdGVuUG93AgEuBQZ6ZXJvZXMFB2xvd1BhcnQAD3piaWxsQXNzZXRJZEtleQINemJpbGxfYXNzZXRJZAAMemJpbGxBc3NldElkCQETdmFsdWVPckVyc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kZHIFBmFtb3VudAULdXNkdEFzc2V0SWQFA25pbAFpAQpyZXR1cm5Vc2R0AAMJAQIhPQIJAJADAQgFAWkIcGF5bWVudHMAAQkAAgECImV4YWN0bHkgMSBwYXltZW50IG11c3QgYmUgYXR0YWNoZWQEA3BtdAkAkQMCCAUBaQhwYXltZW50cwAABANhbXQIBQNwbXQGYW1vdW50AwMJAQEhAQkBCWlzRGVmaW5lZAEIBQNwbXQHYXNzZXRJZAYJAQIhPQIJAQV2YWx1ZQEIBQNwbXQHYXNzZXRJZAULdXNkdEFzc2V0SWQJAAIBAhNVU0RUIHBheW1lbnRzIG9ubHkhBAxpc3N1ZWRBbW91bnQJARFAZXh0ck5hdGl2ZSgxMDU1KQEFFHpiaWxsSXNzdWVkQW1vdW50S2V5AwkAZgIFA2FtdAUMaXNzdWVkQW1vdW50CQACAQkArAICCQCsAgIJAKwCAgkArAICAhhDYW4ndCByZXR1cm4gbW9yZSBVU0RUICgJAQpmaXhlZFBvaW50AgUDYW10AAYCFiksIHRoYW4gaXNzdWVkIFpCSUxMICgJAQpmaXhlZFBvaW50AgUMaXNzdWVkQW1vdW50AAYCASkJAMwIAgkBBEJ1cm4CBQx6YmlsbEFzc2V0SWQFA2FtdAkAzAgCCQEMSW50ZWdlckVudHJ5AgUUemJpbGxJc3N1ZWRBbW91bnRLZXkJAGUCBQxpc3N1ZWRBbW91bnQFA2FtdAUDbmlsAWkBEGdldEZ1bmRzUkVBRE9OTFkAAwkBAiE9AgkAkAMBCAUBaQhwYXltZW50cwAACQACAQITTm8gcGF5bWVudHMgYWxsb3dlZAQHZnVuZFN1bQkAZAIJAPAHAgUEdGhpcwULdXNkdEFzc2V0SWQJAPAHAgUEdGhpcwUMemJpbGxBc3NldElkCQCUCgIFA25pbAUHZnVuZFN1bQDFbzqs", "height": 2778416, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: HVUfaymB7YJtS7qkCw7jrjs3bWhGgAJWSoFBZccjsHvY Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let chain = take(drop(this.bytes, 1), 1) | |
5 | 5 | ||
6 | 6 | let usdtAssetId = match chain { | |
7 | 7 | case _ => | |
8 | 8 | if ((base58'2W' == $match0)) | |
9 | 9 | then base58'9wc3LXNA4TEBsXyKtoLE9mrbDD7WMHXvXrCjZvabLAsi' | |
10 | 10 | else if ((base58'2T' == $match0)) | |
11 | 11 | then base58'6mWwf9mZBjVgkC54idpyaZLQfAosD914wT8fGf2iiY63' | |
12 | 12 | else throw("Unknown chain") | |
13 | 13 | } | |
14 | 14 | ||
15 | 15 | func fixedPoint (val,decimals) = { | |
16 | 16 | let tenPow = pow(10, 0, decimals, 0, 0, DOWN) | |
17 | 17 | let lowPart = toString((val % tenPow)) | |
18 | 18 | let zeroes = drop(toString(tenPow), (1 + size(lowPart))) | |
19 | 19 | (((toString((val / tenPow)) + ".") + zeroes) + lowPart) | |
20 | 20 | } | |
21 | 21 | ||
22 | 22 | ||
23 | 23 | let zbillAssetIdKey = "zbill_assetId" | |
24 | 24 | ||
25 | 25 | let zbillAssetId = valueOrErrorMessage(getBinary(this, zbillAssetIdKey), "Not initialized yet") | |
26 | 26 | ||
27 | 27 | let zbillIssuedAmountKey = "zbill_issuedAmount" | |
28 | 28 | ||
29 | 29 | @Callable(i) | |
30 | 30 | func constructorV1 () = if ((i.caller != this)) | |
31 | 31 | then throw("Permission denied") | |
32 | 32 | else if (isDefined(getBinary(zbillAssetIdKey))) | |
33 | 33 | then throw("Already initialized") | |
34 | 34 | else { | |
35 | 35 | let issuedAmount = 0 | |
36 | 36 | let issue = Issue("ZBILL", "USDT Bill of Exchange token", issuedAmount, 6, true, unit, 0) | |
37 | 37 | let assetId = calculateAssetId(issue) | |
38 | 38 | [issue, IntegerEntry(zbillIssuedAmountKey, issuedAmount), BinaryEntry(zbillAssetIdKey, assetId)] | |
39 | 39 | } | |
40 | 40 | ||
41 | 41 | ||
42 | 42 | ||
43 | 43 | @Callable(i) | |
44 | 44 | func takeUsdt (destAddr,amount) = if ((i.caller != this)) | |
45 | 45 | then throw("permission denied") | |
46 | 46 | else if ((size(i.payments) != 0)) | |
47 | 47 | then throw("No payments allowed") | |
48 | 48 | else { | |
49 | 49 | let issuedAmount = getIntegerValue(zbillIssuedAmountKey) | |
50 | 50 | [Reissue(zbillAssetId, amount, true), IntegerEntry(zbillIssuedAmountKey, (issuedAmount + amount)), ScriptTransfer(addressFromStringValue(destAddr), amount, usdtAssetId)] | |
51 | 51 | } | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | ||
55 | 55 | @Callable(i) | |
56 | 56 | func returnUsdt () = if ((size(i.payments) != 1)) | |
57 | 57 | then throw("exactly 1 payment must be attached") | |
58 | 58 | else { | |
59 | 59 | let pmt = i.payments[0] | |
60 | 60 | let amt = pmt.amount | |
61 | 61 | if (if (!(isDefined(pmt.assetId))) | |
62 | 62 | then true | |
63 | 63 | else (value(pmt.assetId) != usdtAssetId)) | |
64 | 64 | then throw("USDT payments only!") | |
65 | 65 | else { | |
66 | 66 | let issuedAmount = getIntegerValue(zbillIssuedAmountKey) | |
67 | 67 | if ((amt > issuedAmount)) | |
68 | 68 | then throw((((("Can't return more USDT (" + fixedPoint(amt, 6)) + "), than issued ZBILL (") + fixedPoint(issuedAmount, 6)) + ")")) | |
69 | 69 | else [Burn(zbillAssetId, amt), IntegerEntry(zbillIssuedAmountKey, (issuedAmount - amt))] | |
70 | 70 | } | |
71 | 71 | } | |
72 | 72 | ||
73 | 73 | ||
74 | 74 | ||
75 | 75 | @Callable(i) | |
76 | 76 | func getFundsREADONLY () = if ((size(i.payments) != 0)) | |
77 | 77 | then throw("No payments allowed") | |
78 | 78 | else { | |
79 | 79 | let fundSum = (assetBalance(this, usdtAssetId) + assetBalance(this, zbillAssetId)) | |
80 | 80 | $Tuple2(nil, fundSum) | |
81 | 81 | } | |
82 | 82 | ||
83 | 83 |
github/deemru/w8io/169f3d6 28.32 ms ◑