@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: 1701459120 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.06560841, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701459120
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.06560841, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xDE5594576C7B5286699122B719E42DEECC000A4E359BCFFD12D6FADAF84214D6,
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.06541159, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 1.9682e-4, 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
5A88F1BAF6E04185F27D492B4E82751CF721E7781C9803C3770FBBCB9F25FC2BC380ED96A6858786C4399FE2D53202F068AFA1C410D1B323E06D84CF
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00009D1A...C38Brequest_funds
[ 1701459120, 0.06560841, "0000f25c3df408399fd5cc26d5a53c4081f6d6600b04b5ef4e41836d384f8b84c772", "de5594576c7b5286699122b719e42deecc000a4e359bcffd12d6fadaf84214d6", "0x8223ac03ea29c1e8c9a3bac5f4ff4b2786144cf25b74ea6dff1f8a4496970e2c", "0x60c4cee67fc5d56cbb25607becb3636eb8322b79", 97 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000DC3C...E597At 2023-12-01 17:32:53 UTCAmount 0.36715684 UCO
Previous public key
0001EB322338BF2DD2E33917F01C0860145A76299A77827694CD8040E86F368251DC
Previous signature
3C7E58D4A810583DE0858C692E4DBF84324AD22F1BD8221213E665804B1BFA8B207EDBCFDC876BF95D728583F1FE2299E356252889EE9E3AD87788C637938F04
Origin signature
304402205A193A0300D93DAC32F7040DFA490BAFE1E259B791E83D9CB7CA98CDF3B06C7902207A4D2395A0E7A924DE2A552753C7D23B002E84D494B4318D268245F3CFA787D7
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00DEC414E19F32523F299DFF5CB6E8FE9F5A5211D2D836CE4413EFD4FBBCAB04DC
Coordinator signature
184083A99AB7E9DEAC6E4BC8207569DBBFD306EE98B159C7BBA0A61C8111818DF21900AB13E22845624597A4D59902C5FA1B3D181CBC9A5D389FB9B4D7AF6E09
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
CF7187F7469901BC3C1F2F61B242E9AAB15A027A9B4CE2D7ED73CB5DD433E747E837829A2F1DB8CC779FF0B2AD26B340498401703E671BCF99E2A484E77AD606
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
B6A128B64D24AD082926F76DE66C6B601B8A2B2F688914CA094891B1E49D5E9B8154A36A3B09E4760F061F14EB6674BECD577822FBAFF3CF3AC8FFD8D3397A07