@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: 1702128540 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.0199, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1702128540
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.0199, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xCD72232C9B4172B468238DD853356CFE181D706CFA8490C3313F84F933C102F0,
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: 0x00007011C3312E6DD64C930A68B7B5F99AA6FC8FAC555DC1421BADB3091E3786B826, amount: 0.0198403, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 5.97e-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
F55093B6C487FB3A268337840E35286857B2192F9D56831902171CCFC172DF641B7AE99DDFD54A9411FEECEB561564CF5F7C63AFF93537D681FAF154
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00007175...BB28request_funds
[ 1702128540, 0.0199, "00007011c3312e6dd64c930a68b7b5f99aa6fc8fac555dc1421badb3091e3786b826", "cd72232c9b4172b468238dd853356cfe181d706cfa8490c3313f84f933c102f0", "0x420768f9f73cb4b53142981333c619d8301b7c70ca7d0d0d72c908728135717d", "0x38ffef970450720260ca5a212e3535c24d662484", 11155111 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00003251...43E6At 2023-12-09 11:30:19 UTCAmount 0.3516145 UCO
Previous public key
000167DDFCC71F16F61B301A278CDE53AFADA6A9D1A27F29ED3E920128C4EAAF6618
Previous signature
BFBE66B8934C1A5327021E3275D110078834AAAEBD52B5F1D70A93BDB235AB7A440E376CDF1621B740958B14E04E17500D031113D3CE3AEBF0F0190019EA7C09
Origin signature
304402204E6AF4D2BECB228D5E464480377A5AF3E410D6B58588602F77CB05DDC03B6CE502207588F502DD0B65E48053ADCFA35EC38029A7B506FC0B45BB86F319F5CC10C609
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00806294DABD9BD252BD917EE6236FA60DA27FC72AD6250EAB8D825928018C41CB
Coordinator signature
8833043C744BFF8AC59931ADC91F764A2FE3E9B8D584433A197E5282F32D6552A1CE1120DE0174307590AAC72E4ED1AC18485C59A81987130D4C764F13EC4D0D
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
8ECF1EE70BF8FC533EBC174A457BA2F655E705C3B5A8B84AAD97E84C46E92888E779F64C9FF2E2BF6CFF6CA79B5A435BD9C2ECF65D5C3DA5F67DC46188B9930C
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
DD2812BD284B7D13EDBC5027C154F080BAF3FF90EA7A588BDB296722D9BE634713BE8E455D360010D521C78B57BCF7F35DC80741B1A2148E925BC20CACE47F0A