@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) == 0x000066706D704329CA8C2A4153991E2DDACC968622CA10217CA14952EB7ABB966C30
)
]
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: 1702142940 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.0995, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1702142940
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.0995, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xA5362AE4D7682730D5C91518B180379ED7E9BF8125DCECBF3456813C59DAFB4F,
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: 0x00007011C3312E6DD64C930A68B7B5F99AA6FC8FAC555DC1421BADB3091E3786B826, amount: 0.0992015, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 2.985e-4, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
600B561689D8F5BAAAE1859B1C9FAEAD4DD73302EF6BEDEEB9E46647F275866B251DD7E2BC45CA3D9E6417626CA7268BFF8C7C489187BDA52E852378
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00003946...FF70request_funds
[ 1702142940, 0.0995, "00007011c3312e6dd64c930a68b7b5f99aa6fc8fac555dc1421badb3091e3786b826", "a5362ae4d7682730d5c91518b180379ed7e9bf8125dcecbf3456813c59dafb4f", "0xcba8686051c5fc2b49a093613d1379a07375062d3a3709822b4accf8b01cf2fe", "0x5fb228009933a4ee72c4b592886ccbd7c744dc07", 11155111 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00008897...7BA3At 2023-12-09 15:30:07 UTCAmount 0.35777361 UCO
Previous public key
000185DEFB47C794BC9FEB121C2ED924CD6777AF45A89B70C7660163CC185B50C259
Previous signature
F30C9616FFA2C7C464996232D46A871D66AB1B6AE0916794028725377028C0611EAFFE064BFCD1B748899F3398C75082E238DBB700D0D708075D98E07DFBB504
Origin signature
304402202B70A42B2DCCC3461D5B8A6E69799BEA6AF4E9FFDB37C098847843C86B72C31F022067A453E895B7786A654C4056C69087F0698D87A2E33429AD4AB41514D98902A7
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
001E0F1AB4696B31907DEA4EA3F1178EB81AE817EC6691057A41132FE5A6D59D11
Coordinator signature
A15E68D4DFBDE15119AEE2D041A4B0F6E3FB38197FE57DCB8EDDD00C395D2182487CFB1020A982120DAEB6BB491637EAB88443EC0130AF74D8FA66DA7848740C
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
7122C02D6D318471667299892E48C06A0AC9CCB08ECF356F5BB3C8BE3E01CD151C0DF10A829D4F9A9B5BE10B75AEEACA7C22FB10506E9B277B31AA3EE1765F07
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
1BF64FC5385214605208E96C7ABC4625DBEE283CCCB26776657C2EA38FBB2E3A0EBD6CC0B3DA1101611A222FAA62BA261443391611ADB7DB29CE72B16DABC606