tx · 5fgFeiytuhktSbJ3t2nwZiv7TFTKBgvcgAi1o2bFCKt2 3N1q2ieDU25PkmLZxFZrdGxETB1vWeLQo4y: -0.01000000 Waves 2022.02.17 17:38 [1927748] smart account 3N1q2ieDU25PkmLZxFZrdGxETB1vWeLQo4y > SELF 0.00000000 Waves
{ "type": 13, "id": "5fgFeiytuhktSbJ3t2nwZiv7TFTKBgvcgAi1o2bFCKt2", "fee": 1000000, "feeAssetId": null, "timestamp": 1645108761104, "version": 2, "chainId": 84, "sender": "3N1q2ieDU25PkmLZxFZrdGxETB1vWeLQo4y", "senderPublicKey": "EgxqmjPExKP8GAbJQALcx5po8T3xyXNAKUPuvben5unh", "proofs": [ "4S9CKTAibvmohaJcvQTUYJoTrMEuBF5ePTQckPSaPRdhvZPsfrCeA7vJVYQptgtjDG8zCQ2pS95wh5zoiG9FZcC4" ], "script": "base64:AAIFAAAAAAAAAAkIAhIFCgMICAgAAAAGAAAAABFjZXJ0U3RhdHVzUmV2b2tlZAIAAAAHUkVWT0tFRAAAAAAQY2VydFN0YXR1c0FjdGl2ZQIAAAAGQUNUSVZFAQAAAA5nZXRTdHJpbmdCeUtleQAAAAEAAAADa2V5CQEAAAALdmFsdWVPckVsc2UAAAACCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQIAAAAAAQAAAA10cnlHZXROZnRJbmZvAAAAAQAAAAdhc3NldElkBAAAAAF4BAAAAAckbWF0Y2gwCQAD7AAAAAEFAAAAB2Fzc2V0SWQDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABUFzc2V0BAAAAAVhc3NldAUAAAAHJG1hdGNoMAgFAAAABWFzc2V0AAAACHF1YW50aXR5CQAAAgAAAAECAAAADkludmFsaWQgTkZUIGlkBQAAAAF4AQAAABFkb2VzQWRkcmVzc093bk5mdAAAAAIAAAAHYXNzZXRJZAAAAAdhZGRyZXNzAwkBAAAAAiE9AAAAAgkAA/AAAAACCQEAAAAHQWRkcmVzcwAAAAEJAAJZAAAAAQUAA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25mdElkBQAAAAVuZnRJZAkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACCQABLAAAAAIJAAEsAAAAAgIAAAAFY2VydF8FAAAABmNlcnRJZAIAAAAGX293bmVyBQAAAAhuZnRPd25lcgkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACCQABLAAAAAIJAAEsAAAAAgIAAAAFY2VydF8FAAAABmNlcnRJZAIAAAAHX2FydGlzdAUAAAANYXJ0aXN0QWRkcmVzcwkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACCQABLAAAAAIJAAEsAAAAAgIAAAAFY2VydF8FAAAABmNlcnRJZAIAAAAHX3N0YXR1cwUAAAAQY2VydFN0YXR1c0FjdGl2ZQUAAAADbmlsCQAETgAAAAIFAAAACnJldm9rZURhdGEFAAAACmNyZWF0ZURhdGEJAAACAAAAAQkAASwAAAACAgAAABdUaGUgTkZUIGlzbid0IG93bmVkIGJ5IAUAAAAIbmZ0T3duZXIAAAAAnCPX7w==", "height": 1927748, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: 9T7AzoNsvxmEAz51mhk7dtbKEVxkQ9NF45Sc8mR3etZb Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let certStatusRevoked = "REVOKED" | |
5 | + | ||
6 | + | let certStatusActive = "ACTIVE" | |
7 | + | ||
8 | + | func getStringByKey (key) = valueOrElse(getString(this, key), "") | |
9 | + | ||
10 | + | ||
11 | + | func tryGetNftInfo (assetId) = { | |
12 | + | let x = match assetInfo(assetId) { | |
13 | + | case asset: Asset => | |
14 | + | asset.quantity | |
15 | + | case _ => | |
16 | + | throw("Invalid NFT id") | |
17 | + | } | |
18 | + | x | |
19 | + | } | |
20 | + | ||
21 | + | ||
22 | + | func doesAddressOwnNft (assetId,address) = if ((assetBalance(Address(fromBase58String(address)), assetId) != 1)) | |
23 | + | then false | |
24 | + | else true | |
25 | + | ||
26 | + | ||
27 | + | func revokeOldCert (nftId) = { | |
28 | + | let certId = getStringByKey(("cert_" + nftId)) | |
29 | + | if ((certId != "")) | |
30 | + | then [StringEntry((("cert_" + certId) + "_status"), certStatusRevoked)] | |
31 | + | else nil | |
32 | + | } | |
33 | + | ||
34 | + | ||
35 | + | @Callable(i) | |
36 | + | func createCert (nftOwner,nftId,artistAddress) = { | |
37 | + | let certId = toBase58String(i.transactionId) | |
38 | + | let assetIdBytes = fromBase58String(nftId) | |
39 | + | let assetInfoOutput = tryGetNftInfo(assetIdBytes) | |
40 | + | if ((assetInfoOutput != 1)) | |
41 | + | then throw("This is not an NFT!") | |
42 | + | else if (doesAddressOwnNft(assetIdBytes, nftOwner)) | |
43 | + | then { | |
44 | + | let revokeData = revokeOldCert(nftId) | |
45 | + | let createData = [StringEntry(("cert_" + nftId), certId), StringEntry((("cert_" + certId) + "_nftId"), nftId), StringEntry((("cert_" + certId) + "_owner"), nftOwner), StringEntry((("cert_" + certId) + "_artist"), artistAddress), StringEntry((("cert_" + certId) + "_status"), certStatusActive)] | |
46 | + | (revokeData ++ createData) | |
47 | + | } | |
48 | + | else throw(("The NFT isn't owned by " + nftOwner)) | |
49 | + | } | |
50 | + | ||
51 | + |
github/deemru/w8io/169f3d6 18.47 ms ◑