@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: 1701616620 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.40419316, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701616620
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.40419316, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x0B066FE8FBE6C74CB2D08135EFE8784AF9F79D7C568C1B6608AD0FB466EB2DB0,
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.40298059, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.00121257, 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
61AC679FC26715BBB75FBCDC36ED538AF59F67D9631843986CACE40D2ECAB258F9D639938271DAC6F7626823E16854060A29A6ABCCFB4A0EF42EFD91
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00003BEF...D72Crequest_funds
[ 1701616620, 0.40419316, "0000f25c3df408399fd5cc26d5a53c4081f6d6600b04b5ef4e41836d384f8b84c772", "0b066fe8fbe6c74cb2d08135efe8784af9f79d7c568c1b6608ad0fb466eb2db0", "0x5f7865c94f440f4cd2d37967aff553f7e32c752818348cb0cd4690a16b387348", "0xaeb6865782acf391110c34504760749a53164d5c", 97 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00004747...168EAt 2023-12-03 13:18:11 UTCAmount 0.37267671 UCO
Previous public key
000164EEE98243AC57282E892ED26176ABA68ABE66A3283198E0C8EC9B72E98D9BB5
Previous signature
1F95F5662F82E83117289F1289049AE1F05FB38523358556D19D141C5614A82E4553D600AA71458C20EC28F8DEFD46F2CB85FE107279EC1B63A7B5C38B29510D
Origin signature
3045022100F15C2211DEE361B5E41F39F98C816E72FF23B9A78CB791F2A737E59B2D69C1E4022070DF000E40CC81CC75F30A03D2159366F4E0A50F4E49187B935E656F233CFC2D
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00D90F118EB2DBF01A7642A180003095F773D0333F52EC2465C413B4E3CEB20D7B
Coordinator signature
674C921CD8157317F0EE1A4A8B5ABA8ACBF903F052D2ECE61617686367B7607AC27EE018046DDEA2DE2227DFD084E0FA7A5EBA3171B552CBBA939975C5114A01
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
0EF9F7BE00B4FAFCC0CE0DB5220D538FAFDE418C686067D745AEF3D493F27345A06CBFCA958A76F9AF0A627FDE259319126CB8C09F3CFDD5690952A748F5E208
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
FFF7EF1FBC348B272E729294F07A431BAD2BFEC78B635F788E2A27290B464A6B7AB2A7379DEAEECBA0A1B795B870BC186DBD76B6FD681925F8B769C433878F02