@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: 1703716680 do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 49.75
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1703716680
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 49.75
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x3739E963ED0778BD43E55EA9DBD2ACD2EF0B899D6BD324807B0D31A57A611CCE,
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: 0x00005D06DB725180EF960E71D5F2F6A6442D96FC89197F64C3589F0A1ADB22430ECF, amount: 49.60075
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.14925
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
28ED50BD37474E25AFD9D4EDB6041C3A9D72295A4518B1E8AEFA587C87BC09D120F9204768C3E8EE2B80762A00D0C78C52F60EF45A23BE9C52A6CDFC
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00000D17...9275request_funds
[ 1703716680, 49.75, "00005d06db725180ef960e71d5f2f6a6442d96fc89197f64c3589f0a1adb22430ecf", "3739e963ed0778bd43e55ea9dbd2acd2ef0b899d6bd324807b0d31a57a611cce", "0xc7eabefb3d2a81811ecb956ee0b06a394634619c998b3d8f7d448d36ed11dc70", "0x33fd302b0dc65e43b05d8ce01361cdc181410d78", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000131A...FA1BAt 2023-12-27 20:39:59 UTCAmount 0.25164292 UCO
Previous public key
000123C19ED5B9DE91F4EAAA22FCB6C4761802A699065F0CCDA2085C586367DB7A4F
Previous signature
80A034A25B4ED3DDFC4D24DF8AFAE34753D9FB09FD3E9765AD0F94E7D6F2FF083FAC5A444F65972D7285FBFCF9F954C635876AD64BB95C75597EE0C4DB3C0801
Origin signature
304402203ABE8138B96775D298ACD3C33F505515BF4D04555A31EA8634F1911AE94B870902200CB62EF345475B09996AD88A315429DFCD7E3EF0528066136497FB8DF09DF72E
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0092450491468E1BD13CB29FA5DEA623170690100988967D026C745FC4F824F600
Coordinator signature
C079199D9979DF7AF6A6030BA5FC5E182387790667CFFDBDD52D296BABCAC15FA66A21482317AE73C5B57CC2A5C6F296867F9625A236050931BDA4363D1C0E06
Validator #1 public key
00010F2A0E4C424582A94BD90E05FE6931628F91988ABBE387D365994F1F3FCF5A12
Validator #1 signature
225B27AE4AA9C1B2528C8A6AC45D27E89F57FA58FAD483E2A8C8C8C9B15CA8035D19276F957AD903D3FECAAB6CBA94EE9B9756664871CD948F0C8E4E2CEA4101
Validator #2 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #2 signature
C4CC1EB5B702C26764FB5E630D24F6E6CE18BE6E35748EC1B206444CA19DA1FDDC3AB10D3108A05D8AC45999D79872033EE2F590AD356CE9254D05A9D4BCF605