tx · GRyM6FrBGLeEMmpwogHbvzV8fWBt6ZjJb5bnDZdTrHz8
3MtKnDmJju2Y4dp9A2ACPr11jDZiW6gmKKK: -0.01000000 Waves
2022.01.04 21:54 [1864547] smart account 3MtKnDmJju2Y4dp9A2ACPr11jDZiW6gmKKK > SELF 0.00000000 Waves
{
"type": 13,
"id": "GRyM6FrBGLeEMmpwogHbvzV8fWBt6ZjJb5bnDZdTrHz8",
"fee": 1000000,
"feeAssetId": null,
"timestamp": 1641322496201,
"version": 2,
"chainId": 84,
"sender": "3MtKnDmJju2Y4dp9A2ACPr11jDZiW6gmKKK",
"senderPublicKey": "3itc77jAZTQAcaPCyYEe4KD7h18CvqZZ2JRynZHsuJ61",
"proofs": [
"5PHajFwnsB6JSQXXF9WbgDsGADxDaruHgtLdu3FSQ4sop3ZTCyeUcH8nvyvnUC7doCiFpDsNJ6k3etiRMkj1MPUp"
],
"script": "base64:AAIFAAAAAAAAABwIAhIFCgMICAgSABIECgIICBIECgIIARIDCgEIAAAABgAAAAAMYWRtaW5BZGRyZXNzCQEAAAALdmFsdWVPckVsc2UAAAACCQAEHQAAAAIFAAAABHRoaXMCAAAABWFkbWluAgAAAAAAAAAAC3RvdGFsU3VwcGx5CQEAAAALdmFsdWVPckVsc2UAAAACCQAEGgAAAAIFAAAABHRoaXMCAAAAC3RvdGFsU3VwcGx5AAAAAAAAAAAAAAAAAAhjdG9rZW5JZAkBAAAAE3ZhbHVlT3JFcnJvck1lc3NhZ2UAAAACCQAEHQAAAAIFAAAABHRoaXMCAAAAB3Rva2VuSWQCAAAAGU5vIGtleSBkVG9rZW5JZCB3YXMgZm91bmQBAAAAB2lzQWRtaW4AAAABAAAADWNhbGxlckFkZHJlc3MDCQAAAAAAAAIFAAAADWNhbGxlckFkZHJlc3MJAAJZAAAAAQUAAAAMYWRtaW5BZGRyZXNzBgcBAAAADHdyaXRlSW50ZWdlcgAAAAIAAAADa2V5AAAADGludGVnZXJWYWx1ZQkBAAAADEludGVnZXJFbn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FsdWUFAAAAA25pbAkAAAIAAAABAgAAACpBZGRyZXNzIGRvZXMgbm90IG1hdGNoIHdpdGggYWRtaW4gYWRkcmVzcyEAAAABaQEAAAASZGVsZXRlU3RvcmFnZUVudHJ5AAAAAQAAAANrZXkDCQEAAAAHaXNBZG1pbgAAAAEICAUAAAABaQAAAAZjYWxsZXIAAAAFYnl0ZXMJAARMAAAAAgkBAAAAC0RlbGV0ZUVudHJ5AAAAAQUAAAADa2V5BQAAAANuaWwJAAACAAAAAQIAAAAqQWRkcmVzcyBkb2VzIG5vdCBtYXRjaCB3aXRoIGFkbWluIGFkZHJlc3MhAAAAAKmAxME=",
"height": 1864547,
"applicationStatus": "succeeded",
"spentComplexity": 0
}
View: original | compacted
Prev: DViLUWzqxZdaPHRsLMMQv8gn7joemuDszN4sb1sFNMXS
Next: GGvfrA6NRCJKLMB7uEkTFa8V2dtpZehd8H2sd5c9s6vi
Diff:
Old | New | | Differences |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | 4 | | let adminAddress = valueOrElse(getString(this, "admin"), "") |
---|
| 5 | + | |
---|
| 6 | + | let totalSupply = valueOrElse(getInteger(this, "totalSupply"), 0) |
---|
| 7 | + | |
---|
| 8 | + | let ctokenId = valueOrErrorMessage(getString(this, "tokenId"), "No key dTokenId was found") |
---|
5 | 9 | | |
---|
6 | 10 | | func isAdmin (callerAddress) = if ((callerAddress == fromBase58String(adminAddress))) |
---|
7 | 11 | | then true |
---|
|
19 | 23 | | then { |
---|
20 | 24 | | let asset = Issue(tokenName, tokenDescription, 0, 8, true) |
---|
21 | 25 | | let tokenId = calculateAssetId(asset) |
---|
22 | | - | [asset, writeString("admin", adminAddress), IntegerEntry("totalSupply", 0), writeString("dTokenName", tokenName), writeString("dTokenId", toBase58String(tokenId)), IntegerEntry("dTokenDecimals", 8)] |
---|
| 26 | + | [asset, writeString("admin", adminAddress), writeInteger("totalSupply", 0), writeString("tokenName", tokenName), writeString("tokenId", toBase58String(tokenId)), writeInteger("tokenDecimals", 8)] |
---|
23 | 27 | | } |
---|
24 | 28 | | else throw("Pool already setup!") |
---|
| 29 | + | |
---|
| 30 | + | |
---|
| 31 | + | |
---|
| 32 | + | @Callable(i) |
---|
| 33 | + | func buyRound () = if ((size(i.payments) > 0)) |
---|
| 34 | + | then { |
---|
| 35 | + | let amount = i.payments[0].amount |
---|
| 36 | + | if ((amount >= 1)) |
---|
| 37 | + | then { |
---|
| 38 | + | let cTokenAmount = fraction(amount, 21, 1) |
---|
| 39 | + | let currentTotalSupply = (totalSupply + cTokenAmount) |
---|
| 40 | + | [writeInteger("totalSupply", currentTotalSupply), Reissue(fromBase58String(ctokenId), cTokenAmount, true), ScriptTransfer(i.caller, cTokenAmount, fromBase58String(ctokenId))] |
---|
| 41 | + | } |
---|
| 42 | + | else throw("Payment is to small!") |
---|
| 43 | + | } |
---|
| 44 | + | else throw("No payment attached!") |
---|
25 | 45 | | |
---|
26 | 46 | | |
---|
27 | 47 | | |
---|
Full:
Old | New | | Differences |
---|
1 | 1 | | {-# STDLIB_VERSION 5 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | 4 | | let adminAddress = valueOrElse(getString(this, "admin"), "") |
---|
| 5 | + | |
---|
| 6 | + | let totalSupply = valueOrElse(getInteger(this, "totalSupply"), 0) |
---|
| 7 | + | |
---|
| 8 | + | let ctokenId = valueOrErrorMessage(getString(this, "tokenId"), "No key dTokenId was found") |
---|
5 | 9 | | |
---|
6 | 10 | | func isAdmin (callerAddress) = if ((callerAddress == fromBase58String(adminAddress))) |
---|
7 | 11 | | then true |
---|
8 | 12 | | else false |
---|
9 | 13 | | |
---|
10 | 14 | | |
---|
11 | 15 | | func writeInteger (key,integerValue) = IntegerEntry(key, integerValue) |
---|
12 | 16 | | |
---|
13 | 17 | | |
---|
14 | 18 | | func writeString (key,stringValue) = StringEntry(key, stringValue) |
---|
15 | 19 | | |
---|
16 | 20 | | |
---|
17 | 21 | | @Callable(i) |
---|
18 | 22 | | func setup (adminAddress,tokenName,tokenDescription) = if (!(isDefined(getString(this, "admin")))) |
---|
19 | 23 | | then { |
---|
20 | 24 | | let asset = Issue(tokenName, tokenDescription, 0, 8, true) |
---|
21 | 25 | | let tokenId = calculateAssetId(asset) |
---|
22 | | - | [asset, writeString("admin", adminAddress), IntegerEntry("totalSupply", 0), writeString("dTokenName", tokenName), writeString("dTokenId", toBase58String(tokenId)), IntegerEntry("dTokenDecimals", 8)] |
---|
| 26 | + | [asset, writeString("admin", adminAddress), writeInteger("totalSupply", 0), writeString("tokenName", tokenName), writeString("tokenId", toBase58String(tokenId)), writeInteger("tokenDecimals", 8)] |
---|
23 | 27 | | } |
---|
24 | 28 | | else throw("Pool already setup!") |
---|
| 29 | + | |
---|
| 30 | + | |
---|
| 31 | + | |
---|
| 32 | + | @Callable(i) |
---|
| 33 | + | func buyRound () = if ((size(i.payments) > 0)) |
---|
| 34 | + | then { |
---|
| 35 | + | let amount = i.payments[0].amount |
---|
| 36 | + | if ((amount >= 1)) |
---|
| 37 | + | then { |
---|
| 38 | + | let cTokenAmount = fraction(amount, 21, 1) |
---|
| 39 | + | let currentTotalSupply = (totalSupply + cTokenAmount) |
---|
| 40 | + | [writeInteger("totalSupply", currentTotalSupply), Reissue(fromBase58String(ctokenId), cTokenAmount, true), ScriptTransfer(i.caller, cTokenAmount, fromBase58String(ctokenId))] |
---|
| 41 | + | } |
---|
| 42 | + | else throw("Payment is to small!") |
---|
| 43 | + | } |
---|
| 44 | + | else throw("No payment attached!") |
---|
25 | 45 | | |
---|
26 | 46 | | |
---|
27 | 47 | | |
---|
28 | 48 | | @Callable(i) |
---|
29 | 49 | | func updateStringEntry (key,stringValue) = if (isAdmin(i.caller.bytes)) |
---|
30 | 50 | | then [writeString(key, stringValue)] |
---|
31 | 51 | | else throw("Address does not match with admin address!") |
---|
32 | 52 | | |
---|
33 | 53 | | |
---|
34 | 54 | | |
---|
35 | 55 | | @Callable(i) |
---|
36 | 56 | | func updateIntegerEntry (key,integerValue) = if (isAdmin(i.caller.bytes)) |
---|
37 | 57 | | then [writeInteger(key, integerValue)] |
---|
38 | 58 | | else throw("Address does not match with admin address!") |
---|
39 | 59 | | |
---|
40 | 60 | | |
---|
41 | 61 | | |
---|
42 | 62 | | @Callable(i) |
---|
43 | 63 | | func deleteStorageEntry (key) = if (isAdmin(i.caller.bytes)) |
---|
44 | 64 | | then [DeleteEntry(key)] |
---|
45 | 65 | | else throw("Address does not match with admin address!") |
---|
46 | 66 | | |
---|
47 | 67 | | |
---|