@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: 1701432180 do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 9.95e-6
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701432180
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 9.95e-6
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x59F1C946B8974378D390BBA813726A4A4FF71EA2E9EFC3ADD8E59D2CB99EB14C,
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: 0x000052DBB0394202F5E1A0290DC1595870AC160515BE80781452FCB0A205644F801B, amount: 9.93e-6
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 2.0e-8
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
BB456F75633011D226DFEC2DC96D63D5B21BE8BDD6D69742ECA2899C16D6B5A2BF533EC9DA3B2FACFC2E9A7EBE66863001B4B777AF2266C868210AB6
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00008DF3...D666request_funds
[ 1701432180, 9.95e-6, "000052dbb0394202f5e1a0290dc1595870ac160515be80781452fcb0a205644f801b", "59f1c946b8974378d390bba813726a4a4ff71ea2e9efc3add8e59d2cb99eb14c", "0x0742281e15f5a0af970095cf6cce752edd9a81dc210b9b3c570a731b228204f0", "0x4e47dd3cabbab81035d5095b400a312291ae8065", 97 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00003F04...3BC0At 2023-12-01 10:04:18 UTCAmount 0.2592582 UCO
Previous public key
000197B37DFE3C88711D5CF3EF943CE21678899CCDBD9AECF77E8EEF42AFB08BC347
Previous signature
40F7C8AB0C6F944FB5FF20B9BF79E5ACDCCF8892B23E781349A9928D47BEE5F491BEC064ED56D05BD0B277A6A42E96D0DCA1F4149308ADB823097BF4EB2BCD04
Origin signature
3044022068E8CEC064219B8FE6964B0F12B161BADB5A8702721605D38EFB4F748AD7AEBB022014651C92373ED5812FF18C7DE5E1A71C5E52B71D0FCB771D833745A2A568E867
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
009E4EDDF3D5D7922D31BFFBAD62B3EABF8786F072A85B39D618773D30E8DA985E
Coordinator signature
0697F3E290DFEF10F0F18AA7EB9CE1C2C04A725E733717BD5210DDF18FA185FD977C8AE75A635242CD1C432CF23281CC40B7A7634BBFA1033E220348BA4BB70C
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
6641E6B00AB74D93A57ECEFE3B4F7E8CA0A046C6B670169C9968E8A1044509B575565FE65C5BA0A9B4EFF8345130C3A83BBA0D0A020967A962F7762AA8A1A109
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
6E38217E00D15C4D347D254D49D973F00D3BACF33EE21B9AC98A2D943DFE3AE2746F01F0604076ECA351D012BA1531D875AFE176A27FB0E6626CDF9965E6700A