@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: 1706211600 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.00995, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1706211600
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.00995, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x4F8DC5414DA8E01FC0C77320ED1F9FF6BCD4A043A7D095DD09294E39397EA975,
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: 0x0000869E0A51F0357F846FD36618AD57DD2E42A44233E2788B7F1EB543734839F116, amount: 0.00992015, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 2.985e-5, 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
BAEB9EFB63BA9F258EFA8BF27AE31FDA250CF988C2C06174E46C9A45A38F3BA9EC5A4EB6B3504E30F08E57F3C1F6F2384A63352B0455DBDE53F40A53
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00000042...4415request_funds
[ 1706211600, 0.00995, "0000869e0a51f0357f846fd36618ad57dd2e42a44233e2788b7f1eb543734839f116", "4f8dc5414da8e01fc0c77320ed1f9ff6bcd4a043a7d095dd09294e39397ea975", "0x4bde53410019d061260c70bc85289744e58a37e6b0778d105f1164d381b99cec", "0xf35e366b5a709277eb886986a54494a07cc5aa1e", 11155111 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000F2FD...10F3At 2024-01-25 17:41:09 UTCAmount 0.37472258 UCO
Previous public key
00017036C73B073E8E638A43E7B7E8DA14DA2CC01DEBC8A6E8CF66DDE50BA3AE2057
Previous signature
365CAF10C21A4568B78C71FFD16FD2FAD4C4D3379789F43D743F0C2FBEB21EBDB12FF39FBFE9FCE8578F37363AC1BC9CD137010DDA56003F9966B2BA0A3CD400
Origin signature
30440220030FB3A6895F4ACD9C17F4510F0FC6A3DDDE484A8E40937FFFA7BD2E90A58FEE02203CC088F3490B341584996403CAF5324864C003F89249D2C511B37E83A8745272
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00D09FD612A39CB243D97D22FDB151899F448F068AE2D94F127468161AF6C43325
Coordinator signature
8070B5495B29EECF5FC12377D92C5C78709BD5686CE1A861E6DEE2F6D0068BDF899F6A6D5A3428FAA32F5C30C079E8F846AC6EFD9283E865C856CDC4E0180607
Validator #1 public key
000162E6ADFF9FBBBC4BDBB3CD56A5A13A1E8576C3619ADC58A189F7E9A3A77FF95D
Validator #1 signature
5D068F62AF38E76A043E2D56FB949936CF706E02EA2427AED79ECFAA0E741642C9902628A52193A15E53992A36C8B931EF0BD0D565299FD552D057D0A2686B02
Validator #2 public key
00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC
Validator #2 signature
BF9B63857226C21526D8C43C787A1D6AF470DE46328F3B3C69E153C94DA8BC2E4B9B5DD52CA0D6AF9F8B91998C89EE4D6132279DBEC6B6B26E46749E2BBD8407