@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: 1701765960 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.995, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701765960
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.995, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x1FFF5462FDFBAF2C9E389D9AD79BC073BA06AD00747DDD81A953F77C23C5A0D7,
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: 0x0000F25C3DF408399FD5CC26D5A53C4081F6D6600B04B5EF4E41836D384F8B84C772, amount: 0.992015, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.002985, 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
2CEFB71C1A7A605517CCE6271339F6AEA2FB6B5A2B1F859CAF878BF197CE7CF74E33A59C07190B17B7822B0D3DB7BBF8C99EA0B5A52E75EDBF75D619
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000A07C...39DFrequest_funds
[ 1701765960, 0.995, "0000f25c3df408399fd5cc26d5a53c4081f6d6600b04b5ef4e41836d384f8b84c772", "1fff5462fdfbaf2c9e389d9ad79bc073ba06ad00747ddd81a953f77c23c5a0d7", "0x1805a3a8093870fd4de1e265265b6f5ddefa4d6b0cc7990f7cd6cffa817fa1ca", "0x9e346b5e612ddaa9fbed7edcc1b671505d399354", 11155111 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000B60F...0D07At 2023-12-05 06:46:28 UTCAmount 0.36718895 UCO
Previous public key
000113FFACFFB160969EEA0E24137F7E985AE4760F53B3DBCBF561515E5DE3CDAD4B
Previous signature
40CECA8B1EA10ED124E048C48607F75FE02FDFA24C42B24B14D31C9ABB80FA7CB1B8AF45655184766DFCC9CC1322A6D4890403E074A9403B6491F314D4916102
Origin signature
304402203D038813727D6431C6294929E5B7B665CB8B5BB138F99227D54860E9E9CA1E4802204918FD65EFA4E431239146A0FC30E99C743B0AFDC59799DF02A2C45EA37AA426
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0041C3BD974AAEC190D2B375499936E751FEA3F349505E372644F59D3089FEAA3F
Coordinator signature
577205057A641F264688C260C404E2E425B656071922B7573382E167A6FF43CE8E281CD13EF29EF4D974B0ECADE4920F663BAE30756DEB9092E8A36AA445770D
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
4162EB518BB27B6551B16D32589EE4175358435CE896712D70A3F83AEC97D0F8AEE36EF9938F6BE880D25C035FBA2046BE8C64F876CA20B8B352E8CADADC1D00
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
9AF5410A0BE29C61ADDAA808C6261CBB212A3617AF0B6230CB6C556027A470756B2C94ABD43CD5C3F923587E67D2906F04F749F23662F3B385BB16F4FF550903