@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: 1701957000 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.02985, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701957000
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.02985, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x089AF2158CEF11E1ABE37517D655EBB58E6F50D64452AA817D687E94F4DA5C15,
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: 0x0000482A26BDA4D04918F5FAFE8225BA79FCCAB597B00F6F5D06E39C90689BFE2319, amount: 0.02976045, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 8.955e-5, 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
C259A07ED01C2085F0FC39294472F4A52DE6B7055D8A7655EEC69996A74678E35BEDC783BEB1EEED7D36EB2295A075C6F5894049B7C4A7A4A5827F45
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000AEAB...22E9request_funds
[ 1701957000, 0.02985, "0000482a26bda4d04918f5fafe8225ba79fccab597b00f6f5d06e39c90689bfe2319", "089af2158cef11e1abe37517d655ebb58e6f50d64452aa817d687e94f4da5c15", "0x54fdbff22e716cc378eea15db9a5401e56d7af59eedc3ed330f39cb3e8e6f53b", "0x117ff9ed8a21dafda5acd04be1c353128203520c", 97 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00003DC2...4BD4At 2023-12-07 11:52:17 UTCAmount 0.35070159 UCO
Previous public key
00015849AF72CC5448581E3CE72E7AD19975540B187B509092125B383099688AE651
Previous signature
042C03455255A39A18D15B43474355D31B25A8D424C7BA2F148B6E0E802CA19C9A27E8357EB403C0550F9B2CE92D15AA25C78739E426D81EF594BE1DDC2F970F
Origin signature
3045022100FEFD0F81092CA028B0444479FB63599575938AA0FA4662E0821C0B1E45FD0221022026954068F0B529F902ED82960B5CAC977FCCDCFBA46AF9087A65825803B9D0BD
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00E1985E6CF3D1566F488AB021B758629405D742CEE8E187BE94722DC79DDDB1F4
Coordinator signature
4F20C9FBAB20C397E22F1E52202333CC36F681E74969144E757F18092907B69E6C5179582824984BC3577E5FBCEDAD7151CB83F661E1CCE0120D6F514E913206
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
864853FCC6C196587E17AE479E6FCFE508FFC819AAB332FCA1DBD15645B09BC6F0509C00ED57D6DB81FF3343E78A67E538BF1A969F000D46DFB4F7176948640F
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
807B7B7D01906ECB96E7F073E36282561BE4EB4FC5D7903B579C06A9FFB8A6DF0C9D15FB6E5C2169E2478B09F18DBFAE1346241D5EC919D94D72385EE8F28607