tx · D76brpebbXP8T8kPFPHhFE1jCZMUPUnsWRc3kAR74LGH

3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H:  -0.01000000 Waves

2022.11.04 18:24 [2302542] smart account 3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H > SELF 0.00000000 Waves

{ "type": 13, "id": "D76brpebbXP8T8kPFPHhFE1jCZMUPUnsWRc3kAR74LGH", "fee": 1000000, "feeAssetId": null, "timestamp": 1667575501767, "version": 2, "chainId": 84, "sender": "3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H", "senderPublicKey": "BDeCphaaC4MZvfmbJqQZ78EvuEBZTJ1VEW7fbxue8BUu", "proofs": [ "5SQsry42qC4dxqYBwBs1Ny8nsxomdobRCoCnUnEcgM7EsiF2hFqS4Jw23jeyvCT68xDaPoYkSSg3hEeaDVtG39bD" ], "script": "base64:BgIQCAISBQoDCAgBEgMKAQgSAAUACXNlcGFyYXRvcgIBXwAEa0J1eQIDYnV5AAVrU2VsbAIEc2VsbAAGa1ByaWNlAgVwcmljZQEFaXNOZnQBB2Fzc2V0SWQEByRtYXRjaDAJAOwHAQUHYXNzZXRJZAMJAAECBQckbWF0Y2gwAgVBc3NldAQFdG9rZW4FByRtYXRjaDADAwkAAAIIBQV0b2tlbghkZWNpbWFscwAACQAAAggFBXRva2VuCHF1YW50aXR5AAEHCQAAAggFBXRva2VuCnJlaXNzdWFibGUHBwcDAWkBCGlzc3VlTmZ0AwRuYW1lBG1ldGEFcHJpY2UECG5ld1Rva2VuCQDCCAUFBG5hbWUFBG1ldGEAAQAABwQHaXNzdWVJZAkAuAgBBQhuZXdUb2tlbgkAzAgCBQhuZXdUb2tlbgkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCAUBaQZjYWxsZXIIBQhuZXdUb2tlbghxdWFudGl0eQUHaXNzdWVJZAkAzAgCCQELU3RyaW5nRW50cnkCCQCsAgIJAKwCAgUGa1ByaWNlBQlzZXBhcmF0b3IJANgEAQUHaXNzdW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ByaWNlBQlzZXBhcmF0b3IJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkA2AQBBQZ0b2tlbjACHlRoZXJlIGlzIG5vIHByaWNlIGZvciB0aGlzIE5GVAMJAQEhAQkBBWlzTmZ0AQUGdG9rZW4wCQACAQIQVG9rZW4gaXMgbm90IE5GVAkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCAUBaQZjYWxsZXIJAGgCCQENcGFyc2VJbnRWYWx1ZQEFBXByaWNlBQdhbW91bnQwBQR1bml0CQDMCAIJAQtTdHJpbmdFbnRyeQIJAKwCAgkArAICCQClCAEIBQFpBmNhbGxlcgUJc2VwYXJhdG9yBQVrU2VsbAkArAICCQCsAgIJANgEAQUGdG9rZW4wBQlzZXBhcmF0b3IJAKQDAQUHYW1vdW50MAUDbmlsAHMYHRY=", "height": 2302542, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DsLcwqCtckvqSCfr4BeG9ntsTXWq4ZvTQDSTT18qcXJ5 Next: FFUyrG2x2EWNdTsmDSh5GN6A4JQukMuSmiJaHDcR6GBC Diff:
OldNewDifferences
3131
3232
3333 @Callable(i)
34-func buyNFT (nftID,amount) = {
35- let $t0777862 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount))
36- let token0 = $t0777862._1
37- let amount0 = $t0777862._2
34+func buyNFT (nftID) = {
35+ let assetId = fromBase58String(nftID)
36+ let $t0805890 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount))
37+ let token0 = $t0805890._1
38+ let amount0 = $t0805890._2
3839 let price = valueOrErrorMessage(getStringValue(((kPrice + separator) + nftID)), "There is no price for this NFT")
3940 if ((i.payments[0].assetId != unit))
4041 then throw("Pay in waves")
41- else if ((parseIntValue(price) > (amount0 * amount)))
42+ else if ((parseIntValue(price) > amount0))
4243 then throw("Invalid payment attached")
43- else [ScriptTransfer(i.caller, amount, fromBase58String(nftID)), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount)))]
44+ else [ScriptTransfer(i.caller, 1, assetId), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount0)))]
4445 }
4546
4647
4748
4849 @Callable(i)
4950 func sellNFT () = {
50- let $t013591444 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount))
51- let token0 = $t013591444._1
52- let amount0 = $t013591444._2
51+ let $t013571442 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount))
52+ let token0 = $t013571442._1
53+ let amount0 = $t013571442._2
5354 let price = getStringValue(((kPrice + separator) + valueOrErrorMessage(toBase58String(token0), "There is no price for this NFT")))
5455 if (!(isNft(token0)))
5556 then throw("Token is not NFT")
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let separator = "_"
55
66 let kBuy = "buy"
77
88 let kSell = "sell"
99
1010 let kPrice = "price"
1111
1212 func isNft (assetId) = match assetInfo(assetId) {
1313 case token: Asset =>
1414 if (if ((token.decimals == 0))
1515 then (token.quantity == 1)
1616 else false)
1717 then (token.reissuable == false)
1818 else false
1919 case _ =>
2020 false
2121 }
2222
2323
2424 @Callable(i)
2525 func issueNft (name,meta,price) = {
2626 let newToken = Issue(name, meta, 1, 0, false)
2727 let issueId = calculateAssetId(newToken)
2828 [newToken, ScriptTransfer(i.caller, newToken.quantity, issueId), StringEntry(((kPrice + separator) + toBase58String(issueId)), toString(price))]
2929 }
3030
3131
3232
3333 @Callable(i)
34-func buyNFT (nftID,amount) = {
35- let $t0777862 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount))
36- let token0 = $t0777862._1
37- let amount0 = $t0777862._2
34+func buyNFT (nftID) = {
35+ let assetId = fromBase58String(nftID)
36+ let $t0805890 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount))
37+ let token0 = $t0805890._1
38+ let amount0 = $t0805890._2
3839 let price = valueOrErrorMessage(getStringValue(((kPrice + separator) + nftID)), "There is no price for this NFT")
3940 if ((i.payments[0].assetId != unit))
4041 then throw("Pay in waves")
41- else if ((parseIntValue(price) > (amount0 * amount)))
42+ else if ((parseIntValue(price) > amount0))
4243 then throw("Invalid payment attached")
43- else [ScriptTransfer(i.caller, amount, fromBase58String(nftID)), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount)))]
44+ else [ScriptTransfer(i.caller, 1, assetId), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount0)))]
4445 }
4546
4647
4748
4849 @Callable(i)
4950 func sellNFT () = {
50- let $t013591444 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount))
51- let token0 = $t013591444._1
52- let amount0 = $t013591444._2
51+ let $t013571442 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount))
52+ let token0 = $t013571442._1
53+ let amount0 = $t013571442._2
5354 let price = getStringValue(((kPrice + separator) + valueOrErrorMessage(toBase58String(token0), "There is no price for this NFT")))
5455 if (!(isNft(token0)))
5556 then throw("Token is not NFT")
5657 else [ScriptTransfer(i.caller, (parseIntValue(price) * amount0), unit), StringEntry(((toString(i.caller) + separator) + kSell), ((toBase58String(token0) + separator) + toString(amount0)))]
5758 }
5859
5960

github/deemru/w8io/026f985 
23.01 ms