@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) == 0x0000072E418B60C6DABD272BC2728B17B352B8104F068D11365D50134F96A4199609
)
]
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: 1701859800 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.38078501, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701859800
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.38078501, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xD1C48CB6A7729ECD2778701219F2B2EA375BEE8C78A2633180304191F745FF6A,
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: 0x0000F25C3DF408399FD5CC26D5A53C4081F6D6600B04B5EF4E41836D384F8B84C772, amount: 0.37964266, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.00114235, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
49FE69EA2F7106E8A91AAAB31F09667C018F39AAA1EEB1A6AC8491CD12AE87AB6D7EB01647589647E2DF737F281CFDC63ED5372F575C757A2BAA747F
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000FBCD...31F0request_funds
[ 1701859800, 0.38078501, "0000f25c3df408399fd5cc26d5a53c4081f6d6600b04b5ef4e41836d384f8b84c772", "d1c48cb6a7729ecd2778701219f2b2ea375bee8c78a2633180304191f745ff6a", "0x74bdd862a5c190c8f91fd2568896f1419aefee2734033fafa22688f0a6eb733d", "0x90f857c2e6d94da1bd19faf9fff3c5d76088a856", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00003559...8D6AAt 2023-12-06 08:51:07 UTCAmount 0.36643093 UCO
Previous public key
00017E58FDD632932A767884B2B146182090B07ED61E50FCA26C88C16AB6B5FB084C
Previous signature
14C720295D93AB66C71B9B0BC118C9EBE755EB74631A0B57249F2FA3CBC18A4A25C1B70335BD6D793C916BFC5D7EB494F4F99805378B115A205CA2D2DD016703
Origin signature
30450221009A7D8687786326D06D9E5C85A772CFB1DA8347475EF61DBFBF161C2F959456EB02201354AC1DF50E4182A6FB141FB6A4C66989006F72BC4A421DC3CDC001C28E54FE
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
009A49ED1A3C7AFA166FC95341CE35D7E8CA4D9D3F893CD023AAF516FE3979E253
Coordinator signature
1DA03B4D20DB06E7F6C64033BEC64ECB53ABC331CF7964A5CAB97AC82594486A4DF8BDDB9503E7C2F9E7886218FEC734508D163C825E3756A7BA9B151A6B7A05
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
BBD773216FFE53485EFF84D678EFBD1691EAE0F84FD86BDF891768D77331F53C19250A170C4C834E12B67E4D0F948EB1F570601657D8C5794D257EA464988B0E
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
E1A3E169247441E910AF904F6EAF9D07734735D57A47109929EBF6DC0EF6E6173ED2881CC97415B8FFB78197D89818098E864D7A4AF5CA51D6687F7E0228CA03