@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: 1701454620 do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 110.445
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701454620
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 110.445
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xEE05BD37A715FF467EC5E273853B02AE87808D76E94E284EB065C0F8D310ADE4,
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: 0x000027DBFA6C5BE7B6BA69D237DB95C4F481DBA5B608A82B7D98BCB70B2A3A712F86, amount: 110.113665
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.331335
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
9ACE3DC35CA78515608C2C828D571177D89C7C4A6E654B06DE29FDC484092B04F85FEF007B92FC9A0DFC19846BC536F363DEA3DE6DBB2F7B2F1C9987
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00002580...92F4request_funds
[ 1701454620, 110.445, "000027dbfa6c5be7b6ba69d237db95c4f481dba5b608a82b7d98bcb70b2a3a712f86", "ee05bd37a715ff467ec5e273853b02ae87808d76e94e284eb065c0f8d310ade4", "0x00124742182d74c9785e6224e2f67ffaf33f9ed27760c44b2308f4944cfd467e", "0x6c775e908cb86221472a36cfccbac77d452948ea", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 000009CB...4A8EAt 2023-12-01 16:18:37 UTCAmount 0.26532549 UCO
Previous public key
000165A4A07B59F7B38869C1269484E9547685868D3566F872C480BF7F93DC149EC5
Previous signature
73685263A935C7537FED84812F9115FDB36C8FCFE82987E4C26BD313AE2538D0E13606F26E884CDE9C4E377A498089EFBC3C551C48F2C37268BA94AD7EBDD105
Origin signature
3045022100A0AAF3C6E9E5BB65E5DFB8ECFD6D4199A3859C983D63965E19D3440A45F64DE6022025D011E0ED9EE7CFBD5E872FB977BD2D75D85723AD60E37B88861F2BAE53231C
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
002B8405C4C3C8CB618FB50E07D0C5ABFBC6B5057B32D5EBFDEE2DB133F3DE329A
Coordinator signature
7667C37E5F74D3E997EAA23FE5DCBAE95649ADE6A6FFB127EB75A60A1D263938A6FC2DC31F135FFB3636BC4C04D427108C821E049F4A5CED7B3B726AFDAA4D06
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
CB5C0B8276AC400CF47B0756873F2B6F5266FF4CA1361AA64CCAC1ECCB9FB5C5E6DA37C57613A0045A96968E30FD9F65D7F72B9985ECFA6482B4552249AB8F09
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
ED6659D3D34DE8BD3A70128072DAA4DD18D2B1102A97940D2E9EF3E18FA0C437D2658633F99AD5FE7B164D106DE665FCDCA90B1144D59DE182B620118853C60D