@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: 1701803820 do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 0.995
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701803820
]
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.995
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xFD21AA5C1E7EF3E731F0D7CC9DC620ADE275B4463F24FADCF7F90F7EAA06DB85,
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: 0x0000B82D5EA42A09C85F8D358D92CC0CE6BBEA919FB66407691B97F021598610F2B3, amount: 0.992015
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.002985
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
3316ABA82739A5F773014DC75FEF8FFF8719B03CEFF210D551C2DA745E4208622AEF58238A1046AA31F3C88BF011B82259E066ED8A078FF5B8C220F8
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000C134...0FB0request_funds
[ 1701803820, 0.995, "0000b82d5ea42a09c85f8d358d92cc0ce6bbea919fb66407691b97f021598610f2b3", "fd21aa5c1e7ef3e731f0d7cc9dc620ade275b4463f24fadcf7f90f7eaa06db85", "0x339adad71fe51c58fced3bafaf73b81292bb72654ffdf02076f9e75a3fecb82e", "0x2ec90143cf5c5fca18912e02be11d64172d121bd", 11155111 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000401E...6609At 2023-12-05 17:17:59 UTCAmount 0.26324438 UCO
Previous public key
000112ECF2E52CB53070B3F1FCE04EEC14260C1868338B3190E5FE194A620804DD80
Previous signature
4DEC9DF05891A98231EBD6661B427B0D9EE5D91223B50E5340341E8FD81D230E2F819BB2294D5DE3BF887C747E873282FE89F7DB0ABBBEA33D01BA778563AA05
Origin signature
304402204B488839A47FC0FD1339FF9BE9E770B01A6A7A498D7ED9087BF0996A3D80FC140220408F5072C1C694B539BE7C51BD99DC8614BCC3911E15FCEAC82D58006FD83DEF
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00F8474E0809FFBB1909053CAC5D9A12FD0E186ADBD28810F8BB6C000875500F05
Coordinator signature
7DB00C1524CEFBF4F791F921A5DBAE9D547E6E5B9E664AA6E2C0E2972C4EFFDFB9E4D2ABB21BE03042BDF31CCEC845D27818128300957AE0E2F38D61CE545506
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
C08CB10A4EB3B2AD21553D8AAE952F0C89E0A1AC79B8CD188253E45FD4D228E8595745D9F34CCE48FA77BA8304248815923B86D429C6A9A026757568DDB7270A
Validator #2 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #2 signature
5E65964420C8D27B8133E623107D3D773239A3250AB5F82BC9C59D51B5EBE31BA1CC7281B42B3AEAA306F8D54EA5A078BF02580FB9DA51365326FBCBC8F87F06