@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) == 0x00008DD22E7496E86901E9B276A1BE6F9512EB09980CC04C7B76495EF37D5666A709
)
]
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: 1701293700 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.14925, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701293700
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.14925, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x34632C17BFCB5D2A4ECD1B47392628567C684574FEE21B82438C7AF037B61156,
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: 0x00009C856ED9DA892A894103149A40831E478F0EB48EEDBB428D45E8F8887C6B628B, amount: 0.14880225, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 4.4775e-4, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
817DC15ABCCAE163896689A2B6639E9CEB8157FA07EEE1C0EAA7DF62D608AB8489FB19777B81C31F54E025F98109F2C0C724B8FDBDCFF44326A510E2
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00002F4B...114Brequest_funds
[ 1701293700, 0.14925, "00009c856ed9da892a894103149a40831e478f0eb48eedbb428d45e8f8887c6b628b", "34632c17bfcb5d2a4ecd1b47392628567c684574fee21b82438c7af037b61156", "0xabbce1e77d0c095f31a82f6a5fb84e8ec9cc81aa6b74a60692985e87e53072a0", "0xb574effcf3265f4a2c143dbd24b9916d99216ee1", 97 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00000EB1...9154At 2023-11-29 19:35:39 UTCAmount 0.37899913 UCO
Previous public key
0001DE18DFC62306BC8C030E9826B779BE712B16410668DC0C83333B12ED4F9E76E0
Previous signature
34260C10977E20467643DCEA88F13318F26B6C9939B8FC4C407C938775C3DEEA4E17E73A03DF8FC8364C1631541C2DC134C28AAD9C0A2E5CB0647C8E72225006
Origin signature
3045022100A6B9CFAF5D5654C12BB32A77A7E2ABCBED568D8B045A31EF836869525D79884E0220206A730C8FC8059A9503384FF47C496062ECDB43157DB0948AE639AB07221CDA
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0037E3D08A08BCA016E006C6E4E0E230A52C9E2CC7DB26C02E8FFBB85F1915875C
Coordinator signature
F27656F79780C9339D37A4F12D826CD39DD7F324513CB03DA03D4F8D3A68A8D236474C5CBE7BA4963A7EAB99EC6CB8AA00B573BEDE74FEBFD2BB949AA7495A0E
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
7D3EA436DE83021BBC22569D4242A488ABED999FBCDB7F7C13A1DC86E2974D3819486E703ED008C67EF384F14D0E0FE363590EF334F6C5A5E2BBB971D0348E00
Validator #2 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #2 signature
5E8674C04AE6A37DE9021D48CD12E7639BA94C1CC64AD57BF7DB5492EC00355C5CA742B166924D076D7A95074BE80B74E960824F72F808E7016FF3800B9CBD04