@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) == 0x00008DD22E7496E86901E9B276A1BE6F9512EB09980CC04C7B76495EF37D5666A709
)
]
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: 1702144560 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 9.95e-4, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1702144560
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 9.95e-4, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xC6A11E1D9AAD35ECF403B568FC2FB22CA7A15ED390CE7ABAA4DE0B6A8232A9D7,
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_token_transfer to: 0x000066062AE51C8EDDB115B895B4917CF9A25F20A0CDAEEDCFC62085AB197F6B48FC, amount: 9.9202e-4, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 2.98e-6, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
B3B2C08F0DCA75F387E205E6E1EB8AB36E3DEFEEC5974D2D21324E7964E916A97B633EEDDE5B529E58EFAF4C076643591EB08019E00C301574209D32
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00003C4D...67CBrequest_funds
[ 1702144560, 9.95e-4, "000066062ae51c8eddb115b895b4917cf9a25f20a0cdaeedcfc62085ab197f6b48fc", "c6a11e1d9aad35ecf403b568fc2fb22ca7a15ed390ce7abaa4de0b6a8232a9d7", "0xa6f4dcd77268251847096bddb85701b3472b0f919ff2fcb7f595cb992d0606e0", "0xaee753b0dcc9281285f447d7133dbc3c034f6609", 97 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00007C61...AE6BAt 2023-12-09 15:56:29 UTCAmount 0.35256135 UCO
Previous public key
0001AC35591407D5FB03EF568633F2943098A8D028A0CEC084FA60567A9862762222
Previous signature
E45BC5443BA0C436A32D290154F92FE19011B5061E248650EBA60727639D52B5F47E2C917D9F2B029E42881253E4E455AD09E2A929596C4DFBC54CA2EB222F04
Origin signature
304402205F9E124B6F5EB2E12B1959557E18A246C0C66726D245EC74ADCAF598EB20CC0B02202EBBAC78F04B95E11B0FF49A8CC03B78516202F4C67F50A474A1482CAEA22C77
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0083597DBCA07985DCBAADAD472FC1C7A439F4B079E8521D128862901795751E14
Coordinator signature
96B12C0AA2FA3CE733D3F280B8C794E06F649C6C5159058AA926D302B3A5812EE6625CBD92AA7630F648AEF190AB858FC9D10FEA0E401CEA6706E5A3223C6A0E
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
1EE7D7E537127AADE9CBB1F00735250F9766B5DF82EB8E4F7305B84449A2ADF12A809B7900CF2B7F3AE5A7661873ADB2D09ECCBC3150AD74C76C25A9F5426801
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
1C07148D9257408C5059BF635315B92A381A0406804B54DD0CC28C965D54D0CCA803D6263D70FE007F26370330D2F06B6C5A9947023EE64988023C2796BCA201