@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: 1701313560 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.08955, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701313560
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.08955, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xCEBF3E9B5E4257E6F0444146856047F2C4DC4B37CE8A739F9D938A8C0E069D2E,
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: 0x0000F5DE05915F5AB06FFB480B86CFD0A5FCB0306C9037E8E0137014B97AF7C8A748, amount: 0.08928135, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 2.6865e-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
7025295702B0723E862604C8CCF828D739E278B8244B3C624D1804222991317443367B75794E8C8C871BAFDEB2F88DFE438B357FD783D3AC7D1B4A4D
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000C739...C65Brequest_funds
[ 1701313560, 0.08955, "0000f5de05915f5ab06ffb480b86cfd0a5fcb0306c9037e8e0137014b97af7c8a748", "cebf3e9b5e4257e6f0444146856047f2c4dc4b37ce8a739f9d938a8c0e069d2e", "0x5ac2574483b419ebb4abf6c94988228c5f71c22884886cdc29f92ac2a44da7ea", "0x465db9a1a4255b0b04507cd7be8a8a93f3510b27", 97 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00009F8F...C09AAt 2023-11-30 01:06:33 UTCAmount 0.36111333 UCO
Previous public key
000134A00B19F00734558DA177285FFDD2D8C1B508E984079E4E5250A0C6D7480B2A
Previous signature
E35CB0B68DDCA6FC66DDFFBBD6F6BCD86352EA7E4DB83FBEDC70C91F778AAE77CAAD9D8DB3D7B4627D0E0382B6DEB82F6244E9A653E2CDD8A4B920045C3BC201
Origin signature
3045022100FB41015D757737FF6FC8FE649402176B3C939394252CC0982919E498F0343D62022016905DB4BDB1A1871871C77F970AD76BF5AEB149BF88B3D60E2D960BA4038B8B
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0003333A437FED29330E7212878449DE44ADC54CC5DBCC5EA0B7FE7CFCB0910550
Coordinator signature
55231FE59C0DE306FC1E01251ABA0322A9053208CE29F428B47DD9EFA12B42A424F04244FFB6A8E3641BE62089052CEA4D702D282765182BC5C971D09492470C
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
842A6E0E426DD0535E494BFFBD501742B21E1E6B476855BDB827B8D64DD793B7922E6F4264A739E7B604CFA7CDEBE0A62DD40754270FECC992AB3954805CDC0A
Validator #2 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #2 signature
13A6009B3C33CF87D001CC22762BA689CF81AE692574C7F98098C115018B95A76B502916AFBDDE89525099C288A5A54A019FFF84038350E133B7A1E552CC6B06