@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) == 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801
)
]
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: 1702054260 do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 49.60075
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1702054260
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 49.60075
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x377040C30D6B77DE6F90C2B7041E1EEB885902ACE8E55A28F7A20D8B21DA65A0,
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_uco_transfer to: 0x000044A7961401B4CA80169A04E142B8D64334E03ACA15F00C9FBC54BCA89E6D9A75, amount: 49.45194775
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.14880225
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
6E8E92B0B54539752148C89285086A9B0D85D0B71D2773218AD5C7CB172F2165E895FB3742960A21BD074CBD36AE1FED875E0734425DFF481BAF3518
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00001829...CC62request_funds
[ 1702054260, 49.60075, "000044a7961401b4ca80169a04e142b8d64334e03aca15f00c9fbc54bca89e6d9a75", "377040c30d6b77de6f90c2b7041e1eeb885902ace8e55a28f7a20d8b21da65a0", "0xa74dec42243da83f72d83950648c377779775674697697887f7d4a239071f61d", "0xb4c8ecd2aaa13df8ca662e5ce3842951614766ce", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000C988...5FDFAt 2023-12-08 14:52:34 UTCAmount 0.24321696 UCO
Previous public key
000154DB07EC1AFDBF0AF4303CFDC8F837E77D68084747106070409513EC31FAA478
Previous signature
B3952E29E073C5175FB8CE8C04B5F92EE264607C930D2B2875D09C89EBAEE2AB25FF9ADD4874985AD3C986D52835424424FBA17D8D9B519C999E515876F8E104
Origin signature
304402203A431C85E0A5EA6471E9CB0DCE6745AB2663799AE2D2B80C98CFB25BE766DE9B022028FF33E12542FE5ACF33E2022AE4A3AF56FF920514FD0A540E71893F62DF63F5
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0036367599BDB6FA47293EE88B5A9750EB70C77975227E60B083A0BF4FD9D26355
Coordinator signature
04AE440E3EE0554DCC0B6A6128147631FE4307B582DB4F04D8A4C64F8C0AC1DE3F23EF4283E96D0B8836875CABA35DA05BD148604EA29945096C4B7C147B8109
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
58AFFA4AA322B9B0EFECBD3111B35B3665382BEA31AB81520FF13A541A42693B9770949385F3F7081E08C3E7C8AB8A0ECFBEB9096C059C71B4348117A19D7A0C
Validator #2 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #2 signature
9C4DBBDC61A23D45936CF54A58EF2195B2C4ADC39DFA7D44297E584499255A070A31F58DF36B558EFD3FFA1FFEF2030DC3AAE4069AE7E42A6E9FE8DBB7595205