tx · A4UcV74mY3hLiqDmjtdHnwd8x6WWUqanGT1mCfu5C4aP

3PAuPTy3r9nAszkxnSDLcudYXSAV1J2jKUk:  -0.01000000 Waves

2024.03.09 14:52 [4076307] smart account 3PAuPTy3r9nAszkxnSDLcudYXSAV1J2jKUk > SELF 0.00000000 Waves

{ "type": 13, "id": "A4UcV74mY3hLiqDmjtdHnwd8x6WWUqanGT1mCfu5C4aP", "fee": 1000000, "feeAssetId": null, "timestamp": 1709985222910, "version": 2, "chainId": 87, "sender": "3PAuPTy3r9nAszkxnSDLcudYXSAV1J2jKUk", "senderPublicKey": "FUayzMxaWuipFrWABNhM3TFXoaiv36as5x3ipQsf7Pmm", "proofs": [ "wK5wSfk6nxYEwEcivEov7HB1Zm9EHmrdB9t5ZjSqvBwBp7Dji2nySZxmZSbhjWUgLfa9z8cWT5bZ1YtuYdAwshq" ], "script": "base64:BgIJCAISBQoDCAgICgAEZnVkdAEgQHsMDzhOtNXIuUCwZgK73eR+3cH2sC4MYy5Hn0fVndwAD3NlcnZlclB1YmxpY0tleQEgFnrTH5vdoT2zR0vVqSsHnBpjhHXMFSw1mPViPr3AqigADndpdGhTZXJ2ZXJTaWduAghyZWdpc3RlcgAadG90YWxSZWdpc3RlcmVkQWNjb3VudHNLZXkCGXRvdGFsX3JlZ2lzdGVyZWRfYWNjb3VudHMBEWdldEFkZHJlc3NLZXlCeUlkAQJpZAkArAICAgthZGRyZXNzX29mXwUCaWQBEmdldFJlZmVycmVyS2V5QnlJZAECaWQJAKwCAgIMcmVmZXJyZXJfb2ZfBQJpZAERZ2V0SWRLZXlCeUFkZHJlc3MBB2FkZHJlc3MJAKwCAgIGaWRfb2ZfBQdhZGRyZXNzAQ1nZXRUaGlzU3RyaW5nAQNrZXkJAQV2YWx1ZQEJAJ0IAgUEdGhpcwUDa2V5AQ5nZXRUaGlzSW50ZWdlcgEDa2V5CQEFdmFsdWUBCQCaCAIFBHRoaXMFA2tleQEOZ2V0VGhpc0Jvb2xlYW4BA2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+Boxy", "height": 4076307, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: GtApNFHfqRQXXFMfcnuVAja6bTyCfzvw1gL8G71yM2uB Next: 5D87Sa3ZFDToUgJ49LMP6oCYo6pYbjV5qd8bHKo7P2RZ Diff:
OldNewDifferences
2828
2929
3030 @Callable(i)
31-func register (id,referrer) = {
32- let address = toString(i.caller)
33- if (isDefined(getString(this, getAddressKeyById(id))))
34- then throw("Id already exists")
35- else if (isDefined(getInteger(this, getIdKeyByAddress(address))))
36- then throw("Address already exists")
37- else {
38- let totalRegisteredCount = valueOrElse(getInteger(this, totalRegisteredAccountsKey), 0)
39- let userState = [StringEntry(getIdKeyByAddress(address), id), StringEntry(getAddressKeyById(id), address), IntegerEntry(totalRegisteredAccountsKey, (totalRegisteredCount + 1))]
40- let referrerState = if ((referrer != ""))
41- then [StringEntry(getReferrerKeyById(id), referrer)]
42- else nil
43- (userState ++ referrerState)
44- }
31+func register (id,referrer,serverSign) = {
32+ let serverSignedData = toBytes(((id + "_") + referrer))
33+ if (sigVerify(serverSignedData, fromBase58String(serverSign), serverPublicKey))
34+ then {
35+ let address = toString(i.caller)
36+ if (isDefined(getString(this, getAddressKeyById(id))))
37+ then throw("Id already exists")
38+ else if (isDefined(getInteger(this, getIdKeyByAddress(address))))
39+ then throw("Address already exists")
40+ else {
41+ let totalRegisteredCount = valueOrElse(getInteger(this, totalRegisteredAccountsKey), 0)
42+ let userState = [StringEntry(getIdKeyByAddress(address), id), StringEntry(getAddressKeyById(id), address), IntegerEntry(totalRegisteredAccountsKey, (totalRegisteredCount + 1))]
43+ let referrerState = if ((referrer != ""))
44+ then [StringEntry(getReferrerKeyById(id), referrer)]
45+ else nil
46+ (userState ++ referrerState)
47+ }
48+ }
49+ else throw("invalid server sign")
4550 }
4651
47-
48-@Verifier(tx)
49-func verify () = match tx {
50- case inv: InvokeScriptTransaction =>
51- if (if ((addressFromRecipient(inv.dApp) == this))
52- then contains(withServerSign, inv.function)
53- else false)
54- then {
55- let serverSign = sigVerify(tx.bodyBytes, tx.proofs[0], serverPublicKey)
56- let senderSign = sigVerify(tx.bodyBytes, tx.proofs[1], tx.senderPublicKey)
57- if (serverSign)
58- then senderSign
59- else false
60- }
61- else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
62- case _ =>
63- sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
64-}
6552
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let fudt = base58'5Lhv8uKnvGxA2cjbFXXKZFASk1cAFp9dRWkmLYhULtSX'
55
66 let serverPublicKey = base58'2WkbaQskVcGu5BtR8TdRrgHjh7oA1Qk3nBsNumhKMPHq'
77
88 let withServerSign = "register"
99
1010 let totalRegisteredAccountsKey = "total_registered_accounts"
1111
1212 func getAddressKeyById (id) = ("address_of_" + id)
1313
1414
1515 func getReferrerKeyById (id) = ("referrer_of_" + id)
1616
1717
1818 func getIdKeyByAddress (address) = ("id_of_" + address)
1919
2020
2121 func getThisString (key) = value(getString(this, key))
2222
2323
2424 func getThisInteger (key) = value(getInteger(this, key))
2525
2626
2727 func getThisBoolean (key) = value(getBoolean(this, key))
2828
2929
3030 @Callable(i)
31-func register (id,referrer) = {
32- let address = toString(i.caller)
33- if (isDefined(getString(this, getAddressKeyById(id))))
34- then throw("Id already exists")
35- else if (isDefined(getInteger(this, getIdKeyByAddress(address))))
36- then throw("Address already exists")
37- else {
38- let totalRegisteredCount = valueOrElse(getInteger(this, totalRegisteredAccountsKey), 0)
39- let userState = [StringEntry(getIdKeyByAddress(address), id), StringEntry(getAddressKeyById(id), address), IntegerEntry(totalRegisteredAccountsKey, (totalRegisteredCount + 1))]
40- let referrerState = if ((referrer != ""))
41- then [StringEntry(getReferrerKeyById(id), referrer)]
42- else nil
43- (userState ++ referrerState)
44- }
31+func register (id,referrer,serverSign) = {
32+ let serverSignedData = toBytes(((id + "_") + referrer))
33+ if (sigVerify(serverSignedData, fromBase58String(serverSign), serverPublicKey))
34+ then {
35+ let address = toString(i.caller)
36+ if (isDefined(getString(this, getAddressKeyById(id))))
37+ then throw("Id already exists")
38+ else if (isDefined(getInteger(this, getIdKeyByAddress(address))))
39+ then throw("Address already exists")
40+ else {
41+ let totalRegisteredCount = valueOrElse(getInteger(this, totalRegisteredAccountsKey), 0)
42+ let userState = [StringEntry(getIdKeyByAddress(address), id), StringEntry(getAddressKeyById(id), address), IntegerEntry(totalRegisteredAccountsKey, (totalRegisteredCount + 1))]
43+ let referrerState = if ((referrer != ""))
44+ then [StringEntry(getReferrerKeyById(id), referrer)]
45+ else nil
46+ (userState ++ referrerState)
47+ }
48+ }
49+ else throw("invalid server sign")
4550 }
4651
47-
48-@Verifier(tx)
49-func verify () = match tx {
50- case inv: InvokeScriptTransaction =>
51- if (if ((addressFromRecipient(inv.dApp) == this))
52- then contains(withServerSign, inv.function)
53- else false)
54- then {
55- let serverSign = sigVerify(tx.bodyBytes, tx.proofs[0], serverPublicKey)
56- let senderSign = sigVerify(tx.bodyBytes, tx.proofs[1], tx.senderPublicKey)
57- if (serverSign)
58- then senderSign
59- else false
60- }
61- else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
62- case _ =>
63- sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
64-}
6552

github/deemru/w8io/fabc49c 
37.38 ms