@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: 1702534620 do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 1.194
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1702534620
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 1.194
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xCF5D6BA50296535FCF07F760D2F515C89410DAEB288F620AAB2A6C27688F9975,
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: 0x0000714C336DDD8B3DE2F85115B1C5A25A93E1D2241EF8A7279040F22232A821FFB4, amount: 1.190418
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.003582
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
C768C9B12AA16EADF0E8214C4EC92D96C42723973ABE6D4238D948926D08B7002D1719EDFE4B4BEE18072522EAC21E08AC7346916B57F9BCDBAAD709
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00000D76...D6C3request_funds
[ 1702534620, 1.194, "0000714c336ddd8b3de2f85115b1c5a25a93e1d2241ef8a7279040f22232a821ffb4", "cf5d6ba50296535fcf07f760d2f515c89410daeb288f620aab2a6c27688f9975", "0xe363f22e0f8891cde0b749f44feb6b600930e5c5b6af5885b39cbdbafa3d5327", "0x0ae1c20e57f0ed6230db35b6ea9e886d9b16d674", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00000D25...CA07At 2023-12-14 04:17:38 UTCAmount 0.26895339 UCO
Previous public key
000124CFA45CA0AD246D85B53288357DDFF36E8510E2A11C4AA279F09366D4DB5AD4
Previous signature
C9CED0060463CDD0AE4A53482BE7B423D27C5A5F8F42F7D39099ED4C70033C5A234455DA561B546C6FB1CF5AB4F8E52DE4845D2F66E496955B28E2064D6C9A0D
Origin signature
304402206AD0C6B0444021EDDE23C3CD2EA6E8E3F6F6B338185FE9BA7E3889A3440811CA022028DB84649469D69A67550FA188C6837D12828267152892CD02EF1AF1C95D014F
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0042BE702CCE3B7554C688741F455F2DBF5BD5CBDEF860A13873C80D3244BE1AFC
Coordinator signature
0CB424B710E4A61D2DCFBDC9F4E55B32CF8B95239961F51E1EDB51AC3A0749D4B2AE1BB39D0F2DEB6D7E5A03B1A25BDCDCCDAE294AFE75E5AB71BEA0D227F501
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
840656BE5A76075689B00FF3AAC64AEFD4EEEA312CE7A3FC28FC4DF710B51409B5B27D7B86B6216825368A230D5400DF1734FE32B81ABDA96476E8888A842D07
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
C3C604839477F654CCD31BD4D5284CCC118003A65ACA7F4001D25ED9B35E2CBF9EBDFF52C891F48ED6A050376F799FDA6F34EDDEF26C1C6406095D473353640F