@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: 1701397140 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.04975, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701397140
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.04975, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xFD94A1C32AD543FDDCAF7D07109589F3AFF8C692519FF6805E9F8BC40153CCDB,
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: 0x00006DB2CFA00948324EC4D78090B8DC9CF0FCE416F7144B1A681951DF6169CB8A22, amount: 0.04960075, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 1.4925e-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
97EB2B3F9BB257954C35DA9B97D3C32039996C2875E5B9502670C527E0508D990F2184A8155B270FF2797671584DE43FDDF640800F482D219EDD0033
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000395B...18C7request_funds
[ 1701397140, 0.04975, "00006db2cfa00948324ec4d78090b8dc9cf0fce416f7144b1a681951df6169cb8a22", "fd94a1c32ad543fddcaf7d07109589f3aff8c692519ff6805e9f8bc40153ccdb", "0x450ce3c31556905d4bfe6c2bf19aaa35d1ab1e75ab59c52998075c7d7168b6ec", "0xa582a1d992ae2efbd421ca7fd57b7ec73a885050", 97 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000C9F0...A513At 2023-12-01 00:19:28 UTCAmount 0.35448422 UCO
Previous public key
0001A0D01CFAF521A512B48CAA7CB520771ABB82F0B4FED9FD5C20C95AEF47C2610A
Previous signature
0F86176731B2F55F47C1BF79CCAEDB0292A0C0F21BEA4CEB20754F2B9AE0769BDDB047DB6C9DA8A2964D04C797DDE3C3D109735BE3F0C16E425391678B6AA30C
Origin signature
3045022100A47F413F9931B1FB1D6FF7FFC7A787A4021865BED7C732B7DAA6AED3D14CE6D2022033B2E5F0BF0F495A5B03DC3B227FF4339CA6BF0E1279F5C3A43007BB037068A5
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
006865FC70AF6B303E0E4B4A36A605AF7E7040485070FE20B1EA294E893EC0A4D1
Coordinator signature
D7CDEB017265191AC69DC09F632E834A80552DA56E33FA3F12DBEF914A118AA31FDC4AE699057CF2802817747C3A8FF8988CB9B1D6442F3F582FADFA725FB803
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
84789B1E7860F73344F09D452399D400A21D7D73E0BE2D5CDAA960A528654F2DE607C7C0A06CB0ADAB2A5445605D908C2DAF7AA80053549D662B7D498A7D6509
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
0A2753782F40014FC6C761F4150CBBBD0E97B96E1FA2869F8233CBE879B7AC9A15D7258F32D347A6A9BA305CF7F8527095B43EE4F86CA479820A62492E41CF0E