@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: 1702235340 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.0995, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1702235340
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.0995, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x015104C242743DA8DB602579E357FD064323B0D90F500B3DFD3DAAC44BF66084,
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: 0x000095C077FC3ED0DA3281CED75EBF1F307C1D9244DFB5348E9013B82381677FA9F6, amount: 0.0992015, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 2.985e-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
505B01AB91A983A74B0429BDABCC1F5CB53866D7D8DD94C95D60A77638E49079339AF8DDAE0B1199651D3EB2709BA7C729195F081714B78945782C5B
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000C400...014Brequest_funds
[ 1702235340, 0.0995, "000095c077fc3ed0da3281ced75ebf1f307c1d9244dfb5348e9013b82381677fa9f6", "015104c242743da8db602579e357fd064323b0d90f500b3dfd3daac44bf66084", "0x1c3c148cf4447e29e6901af46e7adc94288da24f6d8e59a9d70452082d454b86", "0xb5db3dbdcad4e55f3dd5f13b01aa06d5a31987fd", 11155111 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000BE85...E5E4At 2023-12-10 17:10:14 UTCAmount 0.36796822 UCO
Previous public key
0001BEE9C357CB99AC7F3F8DED574AFFA704FD19CA29F074D6697B3FC553FFF81B9E
Previous signature
7C00E7016CD5B7553DD335986E6AC81B346C4BE0DBE49ED24E4E9FDB3CFEC06ABFBEF689944FD650B615FF35A27B96216AF6FDCD781E42E8BB748C3A0DAB2C02
Origin signature
3044022011955BDE099BC649633EB2C84F478A2927FA745E8C51910C4B04A02965C2A467022071158DEFED2501BA52BA8CE72537304B2E75EF6AF6826A2FB5165B3921A00FC9
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00710B061B97F0F3E5456CCC377231C1E7164C21E84CA70FA4D6D5B680EEF9CE11
Coordinator signature
23146C643DB87327BA2799DDD6F2F605D4E1662F74EA887DCA635E22782C92BE4E230301D0F74D60285F32DDF823DF2DAA7A5C251340BF371725828793A5640C
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
FE5C22F684BA587DDD4B3C6A4E5FE442CE9F13C3D5168ABC112757560770FC8D1CA0B2B28A7E2419D7E8849A2C693E13B93C7DEB9064D1403741EC64CA7C6A0D
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
5ADAEAB7C42BE92D76B627DFD00C71EE29925928507E8B9CA606E52CD2844AC92A97D280C5C8D73432865710CE32C9EF8FC6B50CDF6A63C4A64F9C0C7DC00201