@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) == 0x000066706D704329CA8C2A4153991E2DDACC968622CA10217CA14952EB7ABB966C30
)
]
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: 1705482840 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.199, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1705482840
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.199, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x75741A8C1E3E166D07FF0B914E922166B1DC9B29096153D1CB5B30EC7E81BFA5,
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: 0x00007B3E438A46326BCEEE97DAFB6C76DFF69834B093BC41C685F129CC5A89D9DD30, amount: 0.198403, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 5.97e-4, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
44CE7D87E7126F9302FDB6A87AC82E81504B6F66B71C1CC4D6298DA2A881E5A38078791B24E1A1B3886C0058B10C40116C2589C29F9CABCB50B4F177
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000BA81...096Drequest_funds
[ 1705482840, 0.199, "00007B3E438A46326BCEEE97DAFB6C76DFF69834B093BC41C685F129CC5A89D9DD30", "75741a8c1e3e166d07ff0b914e922166b1dc9b29096153d1cb5b30ec7e81bfa5", "0x16a675ffdf1a0b494023c741bdf2b867d1e5ba28311a28b2c4aa2265b873ba92", "0x818acae269ed9f484a97d540b9d641b9e01bf554", 11155111 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 000041A8...1E3CAt 2024-01-17 07:15:12 UTCAmount 0.35608854 UCO
Previous public key
000165D38805E2891D22063D8DB9AA89D0A05163B5319694DA28A69784555999687C
Previous signature
7A10D0299753CDB4A3B084821AF1A970F48EA0D2E7E83C82743C6C332C0CE2D048FB7A78710690C3EEE281F481CE249CEE3E1C7C18121CCCB82D1A30239DEC03
Origin signature
304402206090C40540032BB39847DAC149C6C7276253A53821911E2BAF86FBB230D8420302207E0CE1B507BC9896FD4AA723304AE4751BCF5CA148F2F5BA3746AA72F33B5F74
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0037B115FB9908C17DFD209AE23A7158256F461B715D16255B7CA414FA91694455
Coordinator signature
76EDA2E4DB648F3910365CD870BCE618895480D36F1F1264D58FDBA51AABE30EF2B53BDA59C9EB65A6F5F3D32F8E20AB1D01CF39A1955E5D2912864307404008
Validator #1 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #1 signature
E52520C2D58AA9CC05E823B62A304CE5A6C93C5371AB714A710EDC606B58CD3F7CC71DF5FC29C2F70D7AA631FE360436DCB9DC00F03F6F7270D40E988CCD8E09
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
A6F68D31BB58206344407BCC029DE739A729F14ABF514542E50CAE59F9584E74BAAF08673B57C9A77D4BFDA13321315394FE534A429DAE2AD235A4C0A5D6BB0C