@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: 1703408460 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 3.98, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1703408460
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 3.98, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xD501EEB73965E2B9B7EBB7E5966523B5475EB7C364CFE8966E090459B90F16AA,
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: 3.96806, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.01194, 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
E116E79B8E766E54CB78897BE47A38A0615FA1482DE324A81A59A85D1E9003B46A2E2F1E8D6F1F1E8E9771D1705606153C24540D5C5E79AAD7F14697
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00009CA5...FCBFrequest_funds
[ 1703408460, 3.98, "0000f25c3df408399fd5cc26d5a53c4081f6d6600b04b5ef4e41836d384f8b84c772", "d501eeb73965e2b9b7ebb7e5966523b5475eb7c364cfe8966e090459b90f16aa", "0x8e608eaf0aa08720ca05b0f17892d7b589cbd92403a8ef8ed3f1abeabb938950", "0x12b3b06f9359c921534ceebe172a0c6cdd1a2823", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000F870...087AAt 2023-12-24 07:01:47 UTCAmount 0.37277597 UCO
Previous public key
0001989C4C879FD4F6EF463ED939FB975F4956EE169413F918B2D2FD7AED03CE4C86
Previous signature
771B2D4276B5FBAEE3BA630C51F1A00B6CD7C832AE22BF236A30100395F10D5AC54CDE19AE85DB3EB2B87C978F4A4C2EE8655A42260322486895C16BCEA4E206
Origin signature
3045022100E011E8FE641250B0C5B88068A8976ADFDFB5D54ACF39AE8D9CE7F429DB96CD2D02204E056F82D0F70B541CA747BA9064A081EFD82839BDB2A67D9251F16992680F32
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0081B55AE0077ECB5E17B53D235F3D9A3B544B7B8DF81AFB8B8FB18C3D18D3D153
Coordinator signature
10C9B5AFA33B566C7735290687CAD11B22A17EFE9FA2EA8F1341E3C489C922D3FD6E859499DF77395DFE932FA1C7FA9CAD96441D4408C2ED1C86EC0D4670CA09
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
0F386376C22831C3DB022605C00C58538E2BAB944B0DDB06CC475EFC52EEB0AB227B86AA9468F6E23244FF10D5D7BE3CDB380D349CF6B40AC2DA6C370DD95609
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
BA692E49AE8B211B914E0E06044A05ADD882E7056BBC853A289012718D05264B4DC02B7C675B41E0BEF971796C861F2E83C4F96303304C00E6FE6F606A14A706