@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: 1701856800 do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 24.875
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701856800
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 24.875
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x91F39C8257F81BA4DFCFE4E76E1CABEACF6AF3FFF99DB94A786D1F6F2E9A8969,
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: 0x000096DD95822B47C090624B412EABBD89BD8359435EF3BDF849AA2786267EE7F2EB, amount: 24.800375
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.074625
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
81A912978911E1180956D373D06CA68FDBA210DD47CE630E121BCA957D20455D44396966FB3602EB8B5DFB8003AF4B64A68D8BEC2B822A7C655C4381
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00003568...55C4request_funds
[ 1701856800, 24.875, "000096dd95822b47c090624b412eabbd89bd8359435ef3bdf849aa2786267ee7f2eb", "91f39c8257f81ba4dfcfe4e76e1cabeacf6af3fff99db94a786d1f6f2e9a8969", "0x72c62d959a33f8e8901e751d792f59e4d2c30e163ea8f3829c0b3a01e78196a1", "0xa03bc84814f80b2552bbd587afe6ebc933bc480f", 11155111 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000748B...4D64At 2023-12-06 08:00:47 UTCAmount 0.26260124 UCO
Previous public key
0001AC8A3B256AF5B004773DCD0B85BB37FC656570216AD36714A633496254680398
Previous signature
21131C46A93064BAFE15CB9929EF3012691D4EFCD18FB583E193AB49A5521C7C7F3F9863D36975E2DAD43740BF7C41DB6AE0BE1FD736B61C4551544C521CFF0A
Origin signature
3045022100F5A793327848FA272FFF1A5745BB329078EFF6891FF90DF84F8C4186BE855C4C02202E381A2DD246B16B9358CC2FC8FB23B28479193650F71A51AB8D914D771F9A77
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00F5881AF071EF9DAE62CCFE5CDEF4FF03DAB28D05193275655ED56995729D944A
Coordinator signature
AE177A813ACAF1372D9984A3E7DA5695D2C6D928B3E9B5F765B29786622F0EA4DE63D0F4BEC5962A7DAC96BD796318A8F66D3303B8DCA330F985B4ACF5EE6109
Validator #1 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #1 signature
3B56CBFE2E510F8D28864190C36981E7BD4CE5327B21ADBE61B033AC6CCDDEF9063A3FE961E718F395DCDF5CBBD41596DE21AF86144DB9E1425D71893D5F8903
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
3F2B96B247D9AEC5D5CEEE2992DEA0CBC76856E7CE8D7216D59641ED3819327EF2617AE321071090BB0AAEA35DFE77C36C0AB0267D9B88FAFB07AFCC25482905