@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: 1702321620 do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 97.71045171
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1702321620
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 97.71045171
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xB8B1E9E2A92097F83BF8A256E55F25E0CACC428B45FB71A490B950D2BC255575,
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: 0x00000BC0EBA2DBCE4455B46F5E51AFAABA6EB4C7FBA1D4E2E6DABD55DC70F9A04D6F, amount: 97.41732036
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.29313135
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
B4B814D5FBFB7549D37FE974A33390520A11BE1EFE7001F6A17110504AB95A464521FDAB5347D5A4FE5736990626B8D175E698396D37A38A6AD8B0CD
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 000080E3...E7E1request_funds
[ 1702321620, 97.71045171, "00000bc0eba2dbce4455b46f5e51afaaba6eb4c7fba1d4e2e6dabd55dc70f9a04d6f", "b8b1e9e2a92097f83bf8a256e55f25e0cacc428b45fb71a490b950d2bc255575", "0x4340366f1272f01dd280b650f7387f53212c94324ee29d9fb7526ebf36cfc82a", "0x2f1578849336a3edbb26eb4c86336e9b38f8ff55", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000597D...E7C5At 2023-12-11 17:16:18 UTCAmount 0.27551428 UCO
Previous public key
0001CE6D49249112989A44B5F29D8303B1CD3D343D0BDC2A986BA2C3176A58CC95F4
Previous signature
E4304AE6A32EC0BC58B60584EC0E705A624947DA9FFA0F635D17B6D5F3E3348775D06153709FCE0AC34DE88B44A2987F67914E8F433255710876E047E1216403
Origin signature
3045022100A0662F3331D872434FC61819F32DA14A595734876AFF6411281E1A7DE93C3CEF02200C91E1070AA0A57220211E7D02C65A429187DE4A0DC0F7796249DA6B88FBA33A
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00F7AABBB2254E5F66E26AB0E3F324BCF32483198635A3E9B0E877960876E804FF
Coordinator signature
F0C76C031CC41E70F944DE648E4914201F18CFECEBF387D7E09A6BC89F49B98F5370D4521759466B91F39292681D4B1A02E3C02D8FF16A556C33E438E3634B0F
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
076945D44F458AFD5E24412F27A0A9E8836CB6CD8DC1967A7E778047E04FE89C0F35AD109CE7FD8540D69A0850237B6AA1C4480CCE2C71BF27F5F019E2C30B02
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
E751E9921143BB17238B3A8ECB1B50B180D0ADD4B154DEF247AC2B270B6566B7702AD239911ABF50F9BFBA7AB3BBFC0CD71B96FECBED81EF86CA4DD29794EF0C