tx · 9xZ3FGXVbxNqSkDzPTjUS1S1UhUiq9DcnGLbuAGPkzks

3N72SETEKtTuaA3YNVYWgVEmXKrRrZYXHGo:  -0.01000000 Waves

2022.11.10 07:20 [2310552] smart account 3N72SETEKtTuaA3YNVYWgVEmXKrRrZYXHGo > SELF 0.00000000 Waves

{ "type": 13, "id": "9xZ3FGXVbxNqSkDzPTjUS1S1UhUiq9DcnGLbuAGPkzks", "fee": 1000000, "feeAssetId": null, "timestamp": 1668053806151, "version": 2, "chainId": 84, "sender": "3N72SETEKtTuaA3YNVYWgVEmXKrRrZYXHGo", "senderPublicKey": "Kwu4LYBMntApXv8t7csxV23Kvc3tvak26wMKK56tA4V", "proofs": [ "23o2x2wgJJmQsikmxsRg1RWxT9E6EEooB4eYeeNnwy27Z4sTcYgBC8kx4nrHGAjQ7Q62rz1zH1uoYSwkTN8NRG8b" ], "script": "base64:BgIQCAISBQoDCAgBEgMKAQgSAAUACXNlcGFyYXRvcgIBXwAEa0J1eQIDYnV5AAVrU2VsbAIEc2VsbAAGa1ByaWNlAgVwcmljZQEFaXNOZnQBB2Fzc2V0SWQEByRtYXRjaDAJAOwHAQUHYXNzZXRJZAMJAAECBQckbWF0Y2gwAgVBc3NldAQFdG9rZW4FByRtYXRjaDADAwkAAAIIBQV0b2tlbghkZWNpbWFscwAACQAAAggFBXRva2VuCHF1YW50aXR5AAEHCQAAAggFBXRva2VuCnJlaXNzdWFibGUHBwcDAWkBCGlzc3VlTmZ0AwRuYW1lBG1ldGEFcHJpY2UECG5ld1Rva2VuCQDCCAUFBG5hbWUFBG1ldGEAAQAABwQHaXNzdWVJZAkAuAgBBQhuZXdUb2tlbgkAzAgCBQhuZXdUb2tlbgkAzAgCCQELU3RyaW5nRW50cnkCCQCsAgIJAKwCAgUGa1ByaWNlBQlzZXBhcmF0b3IJANgEAQUHaXNzdWVJZAkApAMBBQVwcmljZQUDbmlsAWkBBmJ1eU5GVAEFbmZ0SUQEB2Fzc2V0SWQJANkEAQUFbm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FcHJpY2UFBHVuaXQJAMwIAgkBC1N0cmluZ0VudHJ5AgkArAICCQCsAgIJAKUIAQgFAWkGY2FsbGVyBQlzZXBhcmF0b3IFBWtTZWxsCQCsAgIJAKwCAgkA2AQBBQZ0b2tlbjAFCXNlcGFyYXRvcgkApAMBBQdhbW91bnQwBQNuaWwAuZt8xw==", "height": 2310552, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: H7E5moqAsnN6YmXWFpA3weygGmgyhvb4546hCbjsyk4K Next: F7WLkbPxZwuAt7Btq8SbePaDv8FYY42x9hzTKfVnfb3C Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4+let separator = "_"
5+
6+let kBuy = "buy"
7+
8+let kSell = "sell"
9+
10+let kPrice = "price"
11+
12+func isNft (assetId) = match assetInfo(assetId) {
13+ case token: Asset =>
14+ if (if ((token.decimals == 0))
15+ then (token.quantity == 1)
16+ else false)
17+ then (token.reissuable == false)
18+ else false
19+ case _ =>
20+ false
21+}
422
523
624 @Callable(i)
7-func buynft (amount,assetId,nftid,creatorAddr,saleOwner,caller,amountForOwner,amountForCreator) = {
8- let ownerAddress = i.caller
9- let Alice = Address(base58'3N87gU3S3GtPPo5S7dzRehArERGGJh1jwFD')
10-[IntegerEntry("amountForCreator", amountForCreator), IntegerEntry("amountForOwner", amountForOwner), IntegerEntry("amount", amount), StringEntry("assetid", assetId), StringEntry("nftid", nftid), StringEntry("creatorAddr", creatorAddr), StringEntry("saleOwner", saleOwner), StringEntry("caller", caller), StringEntry("creatorAddr", creatorAddr), StringEntry("saleOwner", saleOwner), StringEntry("caller", caller), ScriptTransfer(Alice, amountForOwner, unit)]
25+func issueNft (name,meta,price) = {
26+ let newToken = Issue(name, meta, 1, 0, false)
27+ let issueId = calculateAssetId(newToken)
28+[newToken, StringEntry(((kPrice + separator) + toBase58String(issueId)), toString(price))]
29+ }
30+
31+
32+
33+@Callable(i)
34+func buyNFT (nftID) = {
35+ let assetId = fromBase58String(nftID)
36+ let amount = value(i.payments[0].amount)
37+ let price = valueOrErrorMessage(getString(((kPrice + separator) + nftID)), "There is no price for this nft")
38+ if ((i.payments[0].assetId != unit))
39+ then throw("pay in waves")
40+ else if ((parseIntValue(price) > amount))
41+ then throw("Invalid payment")
42+ else [ScriptTransfer(i.caller, 1, assetId), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount)))]
43+ }
44+
45+
46+
47+@Callable(i)
48+func sellNFT () = {
49+ let $t011731258 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount))
50+ let token0 = $t011731258._1
51+ let amount0 = $t011731258._2
52+ let price = getStringValue(((kPrice + separator) + valueOrErrorMessage(toBase58String(token0), "There is no price for this nft")))
53+ if (!(isNft(token0)))
54+ then throw("Token is not NFT")
55+ else [ScriptTransfer(i.caller, parseIntValue(price), unit), StringEntry(((toString(i.caller) + separator) + kSell), ((toBase58String(token0) + separator) + toString(amount0)))]
1156 }
1257
1358

github/deemru/w8io/026f985 
30.23 ms