@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: 1701387900 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.08955, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701387900
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.08955, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x851160F8460B39A4D7B6A1B0F9D55C7EE13AFBD1E712ED63AA056D6713E72075,
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: 0x0000064F114419DD1BA0B495E4B596513A180BCC4F58643496F0919DCC3B6313BEA1, amount: 0.08928135, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 2.6865e-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
3803930397DADF7D5FD0D05530BC1A4889F947CA33CE0649F5D9AFB06BCEC2E6AC4CB4AF4B804392083F45ABCA3B3274FBE2074C850F1D4C4F221A05
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000F21F...BFCCrequest_funds
[ 1701387900, 0.08955, "0000064f114419dd1ba0b495e4b596513a180bcc4f58643496f0919dcc3b6313bea1", "851160f8460b39a4d7b6a1b0f9d55c7ee13afbd1e712ed63aa056d6713e72075", "0xb368181e6b2b396030b4c85f4e987864e5a3e393b0f4eb94130322bf32158010", "0xdb7b6843dfebc2af663407ef22a488aa1f6f0965", 97 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000A8BD...F778At 2023-11-30 21:45:12 UTCAmount 0.34865973 UCO
Previous public key
0001ABA645E9145806138351749C3780C6E14970C0D5646DB36677C14EDD28C45F13
Previous signature
7A3FD39835988D50FBE89586FB8882B7C0BCD200EA8A8DAF0A17A9FCD9FF4384F98605ACB95689D9FD91FDF78261D5515FF71E6596134F7EEE3B941E33478A0F
Origin signature
304502210082DE27C1638730F71422B5B4404FDA0009EC3EC6374B8A92CE6E7CE9D8E07D3902206D84A4C8F4F082DF3630116FCB7804E83E99B3069CB5E4EBAC58CE7E11018EF3
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00CB00F0B5FCA4FD85424C34E27B255A4A47E9CD300D92C5CEBA1156C65D0FF4A5
Coordinator signature
1FDEFF960D64A43C8D9FCB57BAE040F68A870633EB63180FF2E22CC47D332539975C7FF52D94ADAFD3DC41AC31F5C4508C780F5925B2A900D86CBFD9E84BE305
Validator #1 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #1 signature
B648962F84A7CCB3AE21B2097E6BC269A22D30DB46D3ED73C686B9F258C4A123A777C1D559D486391546863B333BBA79468612C61999F7D559EE4004E6A0CA0D
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
01853B1EC0F5285E0AD537A8940018453551514602AB714CCA8113BB8C3F94453C23C40BC89E02ED9B05516DA974220C9B59B4BF415E8BFDA855B538BBFA6901