@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: 1701764940 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.995, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701764940
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.995, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x9A94C6506966706ECF8249DF3555EDAE6EA981131354F619C52F9365B77D46FC,
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.992015, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.002985, 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
E5F6BDFEEE5441E6F2453B83365248D649AC5C1C8B9FC732E53D93096B3818A61E5591C79E79240D4B79D9575EA39C8CF506975C40BBEE6B025D700B
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 000033DB...E32Frequest_funds
[ 1701764940, 0.995, "0000f25c3df408399fd5cc26d5a53c4081f6d6600b04b5ef4e41836d384f8b84c772", "9a94c6506966706ecf8249df3555edae6ea981131354f619c52f9365b77d46fc", "0xdded9afe00139144c29725a59856d2594fc5b11ca7fc0edfdaf72040ca14bcc7", "0x9b6fa6ae167c07087a7783ce84546e35b35d7e57", 11155111 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000C4DD...F9B5At 2023-12-05 06:29:29 UTCAmount 0.36354053 UCO
Previous public key
000149DD60248EB340ACA064B03C9BE2DAD2BEBFE35B2FB5DE7FE88C4306A81772B8
Previous signature
71D43B518CF21DB58C183F9E6412443363D69F4647A2455337CD5469F5D77BED95195705237F3BB481C873CD87682D32A05D85B646A4E3802F9696392E6D9A0A
Origin signature
3045022100B07B468DDEA740B8C84A4185F395CFB7973ECEA54DA6DEF34773A02B10CB6F930220510A6C10965BD6208C34D7C8B244B36AE8F4B519F4F9B0A7DF8CE461153FF3C3
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
009F453A162721AB4912C1EBEFF3B9A6AD1D18D1606B02793E334808042F60A37A
Coordinator signature
2C8A1069EF4B916C3038E1986E24F1F50C056709815C3DC464F2D9114081255A4CA79E42FF0076BD4352ED0AB3E65AA466C8DC24833869B547641CA075429903
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
EF5BF000B6F599D31D6BC3943A80B6D994AC4273BF2F2C3ABE97C83DBA40829DB106F88CE493D9AD618A55B868131AF15A9EB5A9AEFAB7A722A867B855A09603
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
617A7DDBFD564B5BF6AC238C1BB6BC5BF2096AF073CE1C8C36AD4F6AF9B2A378268FA27E765FAAEE718DE7940B2CF43136B0A59DA75331FDD206C5E879B15703