@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: 1702281720 do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 0.597
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1702281720
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 0.597
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xFAE27291444E4C12182D4049719CFA7653E133918CA0FBBA9A4D8960C38E8C9E,
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: 0x00002C6AD4819EAFF62AAC561270A15B6EDBAA7F8790505D8A9F85079B02F3A4D7DE, amount: 0.595209
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.001791
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
1B9156186C25D8FFF0CCD8436002E74F5BC0146E5D56175854EDEA3BC63B79F8A4B1EECB412B3EC05F19AAC7E027C66F8AFC55006F0A1B9281DB4355
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000F5D8...0F40request_funds
[ 1702281720, 0.597, "00002c6ad4819eaff62aac561270a15b6edbaa7f8790505d8a9f85079b02f3a4d7de", "fae27291444e4c12182d4049719cfa7653e133918ca0fbba9a4d8960c38e8c9e", "0xf10dd39ffab3bd3a3a3074dc55a04fdbee7121401dcddc7ead3ec9bbec817889", "0x998241f881bc84cffd65952fe08c59c0d8c7e9ff", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000C767...3175At 2023-12-11 06:02:48 UTCAmount 0.2691007 UCO
Previous public key
000120D76407C11C7C23D8CF7D35D0F0E76638B9E72DC41A0751A3D3273D3FF07175
Previous signature
90B78B7C3A65A5AD000AB478AB50773D59E38B9186163DEAAFA32FD5B279BDEFB35C4798F8FD619306276AACC7EF7BA1FBC06708983E3CB796C4B8344F820A08
Origin signature
3045022100D8328DAE3482A555EC41779F44187EB71BE860BF9EC264D52E0D786406FB900802201FFDB62B4A24A70720187966FD1D0A24A6317A45D5B7496DF4393B94A8F842D6
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00935FC50C56F3B79C5850A8C71FC2E9D28830EAF2D76DAB8F86E0ACC746AE2FD8
Coordinator signature
D498E52FF3D2A57882194DCE5381B81E29C70E890731B9CF4D0D75FDCDC8BA484121CEBC7AB637117AD072680728012B3EA7132C70D82264B11E90E8FC4CD10F
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
F60840D33958C10AA1B569F3CF69780AF091C590B227D1560DA0335BCE8AA820BCC9057E98C6CC468C5B11F706C78AE8EAFAB21872A944484654291964EA1603
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
EC22B5A84008AED4A8AA553C2B334D08B4C2098F3ECE4DEFF517154155832E497BCF0704FE8512D76C1B6F3B0605F83FEE7E01F91C9F3E64A5DF4BD9EED9550C