@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: 1702141800 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 9.95e-4, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1702141800
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 9.95e-4, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x02A06A5E864D339DB98B16591DB6BA8BD7220AFFE08F0CF5882EBC172E21EF92,
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: 0x000066062AE51C8EDDB115B895B4917CF9A25F20A0CDAEEDCFC62085AB197F6B48FC, amount: 9.9202e-4, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 2.98e-6, 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
3C06295EE772E217CCC9ED47D891B510A6B06B27A63E9EA661FD82030185C18C8C978B2E064AFCF75E7885C4F330F74FF615634DAAD97535F26F4842
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00007105...F15Arequest_funds
[ 1702141800, 9.95e-4, "000066062ae51c8eddb115b895b4917cf9a25f20a0cdaeedcfc62085ab197f6b48fc", "02a06a5e864d339db98b16591db6ba8bd7220affe08f0cf5882ebc172e21ef92", "0x3dc5b3153280c3139121fa98e884d0d42bbab540b70055dfd3b4eb702ab0dfb4", "0x3b4fd79d32ddd30a68d2b4cd1b083890bd11c18a", 97 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000F0F3...A5F9At 2023-12-09 15:26:30 UTCAmount 0.36067044 UCO
Previous public key
000164A119B44012DD3FDEB3FDF4C1DDFB9B3B77DACBC3C6D1994A8D19FE7B9B8B81
Previous signature
6C7A8A446D70BCC4C7E26D918C583FE2793B24A691097117291C091EADA4D52BB69E2A5DD348C8188D19F166E15A2FA8F6678F31814685A5B2B7E6D622173506
Origin signature
3044022073A8FDB18F241B3966D5E39CB49E03EC6A6A3958917A1EFB7892BC05DBFC680C02201D7AE62FB4AE63B93B47EB527704797C5B270B918E964487BEA5058289788B13
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00629C20AD6DAF98B5C5E756C538D5E1C12CF26DF42ADBD8FC3141CA4FBBAC5AF8
Coordinator signature
B9D56CB8DD84996F7CFACF68E4A609254CA6785411B4E636A6494E8FC820AFB13FF10986726574B7BEF63061F5275D2EEEBFE0F300B090CD7DACFB6174F1AB02
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
61FF13AD1517A3567B8061A63888BC719CA13F06257E6851615CA2C16A58A2BB4B680E8165535B129F09E6662A77AA78819007148218475A1E85540BC8F4C608
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
90390C6E4C7AF9D657C30ED1FBA36255EBB105541FDF27BF4A16A0680E1C00BB865ECF30DF427A4E2E27A696922867C5958AAF173A5C3B622DB6FE3A1EFB550D