@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) == 0x0000072E418B60C6DABD272BC2728B17B352B8104F068D11365D50134F96A4199609
)
]
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: 1701467100 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.199, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701467100
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.199, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x515B85F5D1B177F7125C5D39D65209B88D940D795B38E1D2801DDB2EFE369F83,
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: 0x00009D08AC329E856537D0D7289C114134DDB051A1EAB5BB4BC5C3A3E459EC6858A6, amount: 0.198403, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 5.97e-4, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
DF582EC852232608BAC9A1805E17AAA9E4609822E2EAA8AE1C80E582A02CF186F8E998DF315A479B7E36BF58CEC60AED0EA513289D2381CA88F02389
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00002F85...B0FCrequest_funds
[ 1701467100, 0.199, "00009d08ac329e856537d0d7289c114134ddb051a1eab5bb4bc5c3a3e459ec6858a6", "515b85f5d1b177f7125c5d39d65209b88d940d795b38e1d2801ddb2efe369f83", "0xfe60d21ea689282bd034ded464477df56227c12ba725f6cd9f715a2dc5ecdd5a", "0x33da8dd6b460f24ade9effc4c857d1c2b9aab88e", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000D87D...161CAt 2023-12-01 19:46:05 UTCAmount 0.36874364 UCO
Previous public key
000147F52CDE4ED10C9F4B8976293C4C5A66DF3A37518627267282CBDC3B90C81CB2
Previous signature
A2B0E0B2C6F8BD893070ED3551A7B89FACF855D2D2A80814F69B22CF9B27B116582A7C927CF6B3127B5E4221D2117DF66449FB250FB5C5309890D2FC845C6702
Origin signature
304402205E7D6729B407236FE7B968107C815492C80CE4A98A50D5D0FC6398C0B3C8AEDA02202914DCE2C848AD47A148AB2D0B9BD35E3C6D2E5ED4CF963861C9E4114BE634FB
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0074DB6160965F9A0B6B91AA9F9497657E0792532539AD03142846B6D8E6163968
Coordinator signature
13F8DC52327E69F8EC12A2AE6D029FF3583A0F33E8D077CD0930394A0EC1833B1CE6A87CBD695E93ACEB44719854AFB13621C57106CD0CB8506E80C7A1B4D30B
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
DB8E472878A176FAE688577407D92CE105E41530AC6BF19F39E36A53D367C8676E6FE8249ED3435FF1486BF5E3F5A01531DCD950C3AB7ACEE4EC9A6549650202
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
22E1413E7662D0A1D6A55C6B18A799E51DF316A61227959C4A6F62698284AC3BA53874869BAC932323AFF4DDE6A01A0506662320EC92921148500DF829CFF806