@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: 1702114200 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 >= 1702114200
]
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)) == 0xC3EFBD5A0F1378314EB4C258734E365091D6DD5E42A0BD7FEB19184C8678A96E,
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: 0x00001EE45D5601808D91395CB4EADFEBDB43FB535EA932C3EEA2E5BE20AF7394A32D, 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
3443F4CEF371FB44E954A4D2FB80A00C421F14752BA8DD0DF9FEF9C060448D71A354C6E7CB11A7EEB81524B57B67B2A9DA591B571B6561A441ED6ACE
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000C99D...6D8Frequest_funds
[ 1702114200, 1.194, "00001ee45d5601808d91395cb4eadfebdb43fb535ea932c3eea2e5be20af7394a32d", "c3efbd5a0f1378314eb4c258734e365091d6dd5e42a0bd7feb19184c8678a96e", "0xcbfecba8389d5ff5e1c14d0b2fd038381aae19656bbbed3189e5a14d3c901528", "0xe210b99cfd8b5275075d95e5092e543ff372415f", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00000E8B...B0BEAt 2023-12-09 07:30:48 UTCAmount 0.25948364 UCO
Previous public key
0001FDF86E737EBFEFF37E2CC03BB0194B2F3196BB75B8D6DD49BBC43ADDE251DE27
Previous signature
550BB89DC330F8A3D1E570026DBCECE0401EF35B57BBD9BC0484CD9ACC7FEF255F21E2D63B62E3A01FC7566F3627417CEAF26BF1D8BD733EE96DC4F34F1E990D
Origin signature
3045022100BB3A6F8F03F33F48CB7EA696C6B6CB7A84735AB4BA7A2DB4FFF968900257EE2A02205A9EE45F76AF4BE8F20B3C51349C076865E1D176B0834CD0C5D4F83EAC7C3200
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00DCB3ECE36678C159D0E7DC905CC69961B8B7B89E810F9F13B032ADFA02E49CDE
Coordinator signature
294A8471B63659F910ECED58BF871FFD4D019087AD116AF3C44EE7EB77031B90E55385ACBAD0CBB4392DA9F17FF3CE36FDA528818ADC06DF681CC5564560AE07
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
AB6CFFDBDC9B5805B979FC646EED240074866720A0E1CC39C5204BC30C920DB9FD7441C76EC7533D630213C3A2B17A5D52229DAF647A56DA9C87D306D3771206
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
110D6904E6D36BE24A85EB9329C324DC59E9F55DD7188EC6640AFB04050A9509AB1AACAB303285949FC51A521C7C3EC18F84159675D336D791921A05A4CE6305