@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: 1702219020 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 >= 1702219020
]
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)) == 0xDA463EA7C02FF3380EFD70047B179928141A1DB912FD4245CFF14338DE19ADAA,
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: 0x00005F4C53E037645214F5C85A044BC2604168E36EB4493FB422E60E187E5CAC66C0, 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
62A5D481524E0D22A6BCA28679EEB4EEA88D4BCD1BE49C26841FE9142763F775B68A20872D1F47C0E2E775F3306A1D6F767712CECE13CA46FDFE24B5
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00007A20...FE7Crequest_funds
[ 1702219020, 0.00995, "00005f4c53e037645214f5c85a044bc2604168e36eb4493fb422e60e187e5cac66c0", "da463ea7c02ff3380efd70047b179928141a1db912fd4245cff14338de19adaa", "0x86dd130f5da292e48e00f181b9b19d363120d09cfa44b55ac8765efdb4609566", "0xc99e971ac1e39383847b303896814789c9dc95e9", 11155111 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000FA8D...3B0DAt 2023-12-10 12:38:31 UTCAmount 0.3902435 UCO
Previous public key
00012ECF82A63E39D14B7F54858B06D749689465D58B4FFBACB33EF879574C35E048
Previous signature
0CB844AFAC17C93D8D1A6F908848D8EA8501570D03701EC0818A6C1494C734A633BC5071ADD1467BAEE153A97C99322CD34BB2BFD4D9A511C7D3E087B002BB02
Origin signature
3044022046E262921072132DC258A1B4DB213E8C45D043BC6091C7B12CDEBD2F722A4E8002201750CCE1BFDC6EA53B6F7E50118A15AA6324D35EFF0F49ACB0A68FEDB6DB3C62
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0058C5B6B2D19C3DFB1694CA35C3A841AC38B88CE6094B7EAC65C4644372DEFECE
Coordinator signature
152EF59A1E34AC4146D31B2467920AABB69F4703E6E2939C5CC9AE4E66460CC0F3BE4D69FD1FFAFCE881F43950D540F70105DFCE4983ADFF9F58E1A7A780F80C
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
9B1308715510293EE60CDE6E943F90BE6D3D9125870F1EB787B89DDA1F88FBE1DB26133A389137E2E75EA09CEC404879545117703A3D36832489AAE96352020E
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
F035F751C349A1DCA6F8D7E4C247F5971F04300EE6F66324D1A6C530D80A659CD1039CCA575E2EBAF701B5503353E572621A7A6112F62A584D9D21205D484004