@version 1
condition triggered_by: transaction, on: provision(_evm_contract, _url), as: [
previous_public_key: (
# Transaction is not yet validated so we need to use previous address
# to get the genesis address
previous_address = Chain.get_previous_address()
Chain.get_genesis_address(previous_address) == 0x000066706D704329CA8C2A4153991E2DDACC968622CA10217CA14952EB7ABB966C30
)
]
actions triggered_by: transaction, on: provision(evm_contract, url) do
next_code = """
@version 1
# Automate the refunding after the given timestamp
actions triggered_by: datetime, at: 1703677440 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.398, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1703677440
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.398, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x2564375D110CA453BA06BAC3BA8332439B71D105D609326F47829E617AAC170C,
address: (
valid? = false
abi_data = Evm.abi_encode("status()")
tx = [to: "#{evm_contract}", data: "0x\#{abi_data}"]
request = [jsonrpc: "2.0", id: "1", method: "eth_call", params: [tx, "latest"]]
headers = ["Content-Type": "application/json"]
body = Json.to_string(request)
res = Http.request("#{url}", "POST", headers, body)
if res.status == 200 && Json.is_valid?(res.body) do
response = Json.parse(res.body)
result = Map.get(response, "result")
if result != nil do
decoded_abi = Evm.abi_decode("(uint)", result)
# Withdrawn status is 1
valid? = List.at(decoded_abi, 0) == 1
end
end
valid?
)
]
actions triggered_by: transaction, on: reveal_secret(secret) do
Contract.set_type "transfer"
Contract.add_token_transfer to: 0x00003A8C3917FFA83A114BAD004A003EFDB568EB71555E9B79AAB9CE84651D48E378, amount: 0.396806, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.001194, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
171ED134E0D247340CCCC09AF062D2664E1A9F0D8DDC06CAEB3DAC6F5B479142CA5A2F2352B7DB99062E33BE8893DE63914684E88F2EE19FF056BAB1
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000C79C...2220request_funds
[ 1703677440, 0.398, "00003a8c3917ffa83a114bad004a003efdb568eb71555e9b79aab9ce84651d48e378", "2564375d110ca453ba06bac3ba8332439b71d105d609326f47829e617aac170c", "0x6f3cff4894d05b48ca8347403da2d645f1c2ad12aed948b6d740b2e2558e4b2d", "0xadc7631fa5d47169cfa79ae3e6061f7c257a45db", 11155111 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 000066BC...41ADAt 2023-12-27 09:45:41 UTCAmount 0.37121722 UCO
Previous public key
000124DC2F5D0F403F8DC2C5B21B660CC69777CCF1A020F8782A785F651C67CB9B85
Previous signature
833A7C24F1052F94D3452C85940C4CF823DDE1F5C3661F01008FCF2353C55F9D8C7C787C5AA69ABB557A8734CF506D5769FBFC9CF53D36DE6E6ADB040515D201
Origin signature
3045022100A6C78BE303A2BF8F42B6F022F1169FF732788FEEB7B77646EE2D40DA166BC44802202DA081FB2F7BF7061EA20C97D83AAF9F3CE785E68FFD92A53C2269C0361E999D
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00139858DAB7257A2DF144FE1BE0143BBE6D8EAB3530800B8CB32FB6487778364B
Coordinator signature
5553E3861FD9A3CC80BADDD226D83C6FFA61B1CF1A2ED84D0B4372F6DD073F4EFE5666958E00C234EABA9287F99ADB1F0DFC35806CF7607AC7E4A19A9197A109
Validator #1 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #1 signature
C9F14126C3260BAC49091840E50E8F8715E6521A9682508A6D0B41CBA7ABD742323747291FA05A3AC7FC088F6CD59F8E8BE10AC5DCF299DD74BC78C4F80B140D
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
EA639A81D148F5B882D9985E93DB6C8263AD8FE27FC8A66046BBB3736118AF24781ED182CB6350FA44C5131AE938A02AD49848B452455F6ED094C32BF2A4F20B