@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) == 0x0000072E418B60C6DABD272BC2728B17B352B8104F068D11365D50134F96A4199609
)
]
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: 1706204640 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.0995, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1706204640
]
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: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x6345455D2959076B6EBE07775EE0449A94BE89F0D9F9CEBB2A3579FC7002E806,
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: 0x0000B9A35F1E8BC5592D6D001D00807E0262C8E8F306A860B3530BF5461E85FB3442, amount: 0.0992015, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 2.985e-4, token_address: 0x00001A4AB7AD0CE2B494C965C66FF2962692A5FE5ECB71B345ABB53BAD88A83A01F1
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
50C226D254891857E16C870894C7AA201434B061C52DE29C1AD5668A6336C8FDDBBCAE95B100FD151D7508812F85BA866099255B71A687EBC709BE2C
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00004219...3B62request_funds
[ 1706204640, 0.0995, "0000b9a35f1e8bc5592d6d001d00807e0262c8e8f306a860b3530bf5461e85fb3442", "6345455d2959076b6ebe07775ee0449a94be89f0d9f9cebb2a3579fc7002e806", "0x108911e84a9bc27078bb9a348a1dd8c286787b80c5a2b7052adb98303319473e", "0x76eb5f0508ae88df291448b491e662d41e81124f", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00000893...D561At 2024-01-25 15:45:22 UTCAmount 0.37615409 UCO
Previous public key
00011DA5211E88E830B017FB34E7E682D951746E0067A2D03460F4B1D25A17D19159
Previous signature
B06A16B70140DE5DDB3FC54A2A0BDA4C8EB7487E17A07BD63C17E92BD4027BCE180529D5041FEA0F28E7879D2AB9968EEC5639B48C5723CBBE8658CD3CDEF203
Origin signature
304502210087AE414A5F654FC6BBFDB79A978E85AE2251C287A1B89133C6B14702F952DD5B022022873204F323D8B601E504955B1E2FEFCBB5B543C4B5A37512AEFB9B01F707A1
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0081920534A8FD2C1744DD6574DABBDBF4E8C70DD1B9CDC92DEB5373565DB35041
Coordinator signature
5994791FE178A460CDE2A103CB49C709B018D35642D49C255789E932FBA402283806CE803569F2BA621761D340FB81FBFCCC20E48771B6C5452CDCFD968F6A0F
Validator #1 public key
000162E6ADFF9FBBBC4BDBB3CD56A5A13A1E8576C3619ADC58A189F7E9A3A77FF95D
Validator #1 signature
3F77EF767BB83BE3A1D8177D2C175B1F12EB99C8EFDA141CDEF3B95B7F66EA52D066E32A0EE2C728F01A4B831857DFB56432FEFF3F307E8F485AFB5DFCB51806
Validator #2 public key
0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34
Validator #2 signature
9158A84A1EC188E90A8798C995DDF75088934D46008FB5D1D170DF4859C57D2FDC61631D9DE96445E338B6270460F6EA55CFA59C057DE50B64CD0FFA76E1510C