@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: 1701347220 do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 14.925
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701347220
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 14.925
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xE1F181B78C4783809D91B1EF4026C38A0E7CB207847B02443ED37D7ABC1490B4,
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: 0x000079E07D373D5DD653A6F406D38890A6EA8DFE20708C323B3B576AAD469DCA9984, amount: 14.880225
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.044775
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
912E14FF0487FECBF7A089673CECA4CDF9590DC32DBEC9440CBD75D1DF29700A269D41A5BC7D395A14E22E3E58419364933E5D998E816C6CC840346D
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000A49F...E521request_funds
[ 1701347220, 14.925, "000079e07d373d5dd653a6f406d38890a6ea8dfe20708c323b3b576aad469dca9984", "e1f181b78c4783809d91b1ef4026c38a0e7cb207847b02443ed37d7abc1490b4", "0xaf071c0f04df1324386454e6030e0d8f17be20b94b12613056464a81fb7fb752", "0x1c97f54d9c05cf077829e3c2c1dc999262e4c448", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00006F1E...8DD7At 2023-11-30 10:28:03 UTCAmount 0.25870291 UCO
Previous public key
000190A4FF4492CEAC996E9162F1227D7DBA13464EEF788412FA241F1A3949A65859
Previous signature
85C736D7E4EA067FC7E799A11154328A7AA360F5B5A6D2A8324DADFA30E38E4C01BA39C0305A295E3BF1924491F411FA8F3C72801834CFB6F5740955F4EB7101
Origin signature
30440220575BFDBC17A6BA677795BD0810C9695ED4439FD343207BBE65527FBBDE8098B902206F49E30DC86A322734571C8C17343AAA88BECE5F29399573DE26DB423A542333
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00952896BB49530E7E55D85998FEA2C4A733692DE2389412BB68F6A245103B4CFA
Coordinator signature
19C2ECC787E1DACCAB79CB14EF816318BE1F30770EE02D9B0D6353D1655EEE8379AC502155B593FF5479D34C033739226E763143F02DE89FCB6B47C8CF4E090F
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
35DCB9EE878F9B4B32007A42B80926D27FDF789143CB206F567C821D4A4EB02185B3563CA51E920827B88D10A48C8FA75D0251674A0C3EA687D5EBFFF5DF270A
Validator #2 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #2 signature
4A9664C410FE8B2EF12E96AAB79F69E36D5EECC707C5C140674A1DA1E69767EBE715B883C73605DCA9CB4B2FAED48DDE3E22CC96EA8BFD7684EA61B70223AF09