@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: 1702058940 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 >= 1702058940
]
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)) == 0xFBE7EC5F1B72BFCD21D153C1A5F343199108405C6DD17E14D30C26B91C8084C3,
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: 0x00002AA612CF2E7D8E6C67C3FC8579AA067D89B98E76F1F41528C810E6A8514FCC60, 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
231CFA4B3AE1064C20C920D57848331275C3CC12828D8A2575D7550356343C0EFFCC5D89E020705BB49D1657BF85A68330A847A2E331F6D1C0FD6A44
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00004410...D6DArequest_funds
[ 1702058940, 0.00995, "00002aa612cf2e7d8e6c67c3fc8579aa067d89b98e76f1f41528c810e6a8514fcc60", "fbe7ec5f1b72bfcd21d153c1a5f343199108405c6dd17e14d30c26b91c8084c3", "0xf1b849afd57434b64f160108262f6b19211c7fc0d7dc60fe51c3e21cdbd552d3", "0x75d0608cd9f8410af6c9e4554612c281dd62bc62", 11155111 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00009C71...66CEAt 2023-12-08 16:09:29 UTCAmount 0.36753001 UCO
Previous public key
0001FDCB850CCD7C9D4AA097A96E798AF904549C7DF5AE09BF158B93F76C3FB74277
Previous signature
EA91C798199227D262B8471D5DC32A70DE6A89430C0B22542BAAD16B7FC73714DFFC21AD68F79DCD3E8D95CD0824F4BD53B0C84DBE4B3D70072F8B2B45262C06
Origin signature
304502210084BC74DA51FC8995A5CA77EB210DCD448C4C04AC847123F17950266C6AC53BEC022067154358FFA41156AEA0F0865B51C5B9032E50E67D5052E86C74CC6A670EE2C4
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
005931FDF6ACD36F8768EFF878BC41A1097772BE8713418C6D9DD2A61E902CBDEA
Coordinator signature
1472DBB14E7246F3210EC10C548C9C73840536FC55D68153DCA3487C471496503EBD1669CEE3D4B2F982A50599B49F3096BA3CB78CCE869A0528935013427E06
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
5A64D4E1F38B9C634287BE4F1BC22026EE25D5740B95D0F693BA10AF8CBB752AA1AE28C414AB4B4DA38BFF8BA75FDD1D8F169EF9D996A0DFFA818F01A3A7A300
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
37CC3B5C067C5B3894BEE0E63770D0C58AAC3DAF9DD11E2F1BB87D16F762C27BDDA861E436F240702155F85AD7E1C881A1FD0299D321577EC334A7DE98A4D50D