@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: 1701856140 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.40528796, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701856140
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.40528796, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x23B8BA07DB33E7D36FDBC05D1C07984E4AD3249C1D7E63ACFD321B5D49AA06FD,
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.4040721, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.00121586, 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
B66E5931BFEB9D1586773685F35EB30C2E90D40524E4E3CF3B0917D63378003F57EA4233DF9014536B9456DC603F3ABBD9C20B413E7B1D2A8ED60476
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000B0AF...E001request_funds
[ 1701856140, 0.40528796, "0000f25c3df408399fd5cc26d5a53c4081f6d6600b04b5ef4e41836d384f8b84c772", "23b8ba07db33e7d36fdbc05d1c07984e4ad3249c1d7e63acfd321b5d49aa06fd", "0x8da21a8c6e3bc6f5e4bfb56a11c3e3eb839f47e0e132761be902c31bcabd9ee0", "0xe7d333bc78803b0feb7f402c648ec6976028a556", 97 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00003C25...07D5At 2023-12-06 07:49:22 UTCAmount 0.36626913 UCO
Previous public key
0001D06E051ABE944959C3A3F64CA4F6E359BD08E44612AE92B8BFE27B9A9B316971
Previous signature
61AB12B178C85BD233C89D6164A4980BA54B2B0B265CF5AD7FFFD3446690F21C9989FD5C6AB281BBF99760D5C352312BD96AC1703216D50CC0E781EE51723609
Origin signature
3045022100E75EE87A1AF3BC13A4A4695DA2E6993D2067263B6AB53280D4BB0DBCBE6E94B902204096B03BE62A184E22D2CBED0C8DD0AEB5AB3616D48212146DE2AF5BCDF7F489
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00E8DD3AE8C039F193A9123344750825E043C1F86E1F8DDC8A9E30DFA4DDB01B0E
Coordinator signature
AB1B853EF6B1C14763D007E64DC9B1F5AA0FC9F0653C0FB11A5E37764B2CAF28EC7AB6AA54366F8A9777C3E13AC7A0D91305D8B64CB86657B0BED722B7A7CE0A
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
C7809CF2D890176ED5870F67E52DAFF49DFFBA723B2E45B4E828A6B1BC12A62A8AE233DEA6779CBE2BEFAE8DE583294C4D0BDE27D1EE226683D80712E6D23009
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
6396C233CC5BAE12C2A9253129A8A26F5FEBF644E97466F2CE226E00530BD5FEB82FEB367F59E05B8CF8B122E70520FFC1924095B1EC5DAC894878ADFDF14D0C