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+3cH2sC4MYy5Hn0fVndwAD3NlcnZlclB1YmxpY0tleQEgFnrTH5vdoT2zR0vVqSsHnBpjhHXMFSw1mPViPr3AqigADndpdGhTZXJ2ZXJTaWduAghyZWdpc3RlcgAadG90YWxSZWdpc3RlcmVkQWNjb3VudHNLZXkCGXRvdGFsX3JlZ2lzdGVyZWRfYWNjb3VudHMBEWdldEFkZHJlc3NLZXlCeUlkAQJpZAkArAICAgthZGRyZXNzX29mXwUCaWQBEmdldFJlZmVycmVyS2V5QnlJZAECaWQJAKwCAgIMcmVmZXJyZXJfb2ZfBQJpZAERZ2V0SWRLZXlCeUFkZHJlc3MBB2FkZHJlc3MJAKwCAgIGaWRfb2ZfBQdhZGRyZXNzAQ1nZXRUaGlzU3RyaW5nAQNrZXkJAQV2YWx1ZQEJAJ0IAgUEdGhpcwUDa2V5AQ5nZXRUaGlzSW50ZWdlcgEDa2V5CQEFdmFsdWUBCQCaCAIFBHRoaXMFA2tleQEOZ2V0VGhpc0Jvb2xlYW4BA2t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Boxy", "height": 4076307, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: GtApNFHfqRQXXFMfcnuVAja6bTyCfzvw1gL8G71yM2uB Next: 5D87Sa3ZFDToUgJ49LMP6oCYo6pYbjV5qd8bHKo7P2RZ Diff:
Old | New | Differences | |
---|---|---|---|
28 | 28 | ||
29 | 29 | ||
30 | 30 | @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") | |
45 | 50 | } | |
46 | 51 | ||
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 | - | } | |
65 | 52 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let fudt = base58'5Lhv8uKnvGxA2cjbFXXKZFASk1cAFp9dRWkmLYhULtSX' | |
5 | 5 | ||
6 | 6 | let serverPublicKey = base58'2WkbaQskVcGu5BtR8TdRrgHjh7oA1Qk3nBsNumhKMPHq' | |
7 | 7 | ||
8 | 8 | let withServerSign = "register" | |
9 | 9 | ||
10 | 10 | let totalRegisteredAccountsKey = "total_registered_accounts" | |
11 | 11 | ||
12 | 12 | func getAddressKeyById (id) = ("address_of_" + id) | |
13 | 13 | ||
14 | 14 | ||
15 | 15 | func getReferrerKeyById (id) = ("referrer_of_" + id) | |
16 | 16 | ||
17 | 17 | ||
18 | 18 | func getIdKeyByAddress (address) = ("id_of_" + address) | |
19 | 19 | ||
20 | 20 | ||
21 | 21 | func getThisString (key) = value(getString(this, key)) | |
22 | 22 | ||
23 | 23 | ||
24 | 24 | func getThisInteger (key) = value(getInteger(this, key)) | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | func getThisBoolean (key) = value(getBoolean(this, key)) | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | @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") | |
45 | 50 | } | |
46 | 51 | ||
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 | - | } | |
65 | 52 |
github/deemru/w8io/fabc49c 37.38 ms ◑