@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: 1701554700 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.0398, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701554700
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.0398, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xE2A5EDE7C01884701E6A220E87E5B4200F830188E2763499AE7395D7AB649D95,
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: 0x0000064F114419DD1BA0B495E4B596513A180BCC4F58643496F0919DCC3B6313BEA1, amount: 0.0396806, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 1.194e-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
FECCC0148719A8D820A074712AC04BBE1473568C87DBBAED4E883D1B836B77EFC3D98EA3A629260EBF9002300F9F7886F2E003AEB18D97A182554119
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00003078...836Drequest_funds
[ 1701554700, 0.0398, "0000064f114419dd1ba0b495e4b596513a180bcc4f58643496f0919dcc3b6313bea1", "e2a5ede7c01884701e6a220e87e5b4200f830188e2763499ae7395d7ab649d95", "0xff5ff0268fb766dbba98187c689e359e30169c28ddd46810bcdcf8be8fbc37d5", "0xa8c661fc4e77cb6878033d39e46803c6c8cb0ee8", 97 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00007A1D...0808At 2023-12-02 20:05:39 UTCAmount 0.35610017 UCO
Previous public key
0001156DB089730F0BEB8F09B16059B19A405875A1AB170F1BF6FA595DF2BB5A09F9
Previous signature
F8BCA0431ADA720FA17A964E714F5A595D105A288452846A11552888EAB599AE0CF64C6802F42DFB4DE71DD08A7F78E9E784CD7322A0F403BC58138E1900F50F
Origin signature
304402203AD148E391C74E4C02B3C64CAE7CB5ED61AE24CD2F398EE982BD22A18C19A1D202204BA29C8BD3E55AC09C1363CA952778E1B5769763FEEFF32413B6DE1794713680
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00C7AD3F2E6531C0585B2153227D1026ADA643B7D4A9DB16FA5255D19FEB035141
Coordinator signature
3239320089AC07DAB78EE3F0197E84E11BAD12164B4209CF3775A34E09AE6639F6AC783CFDE5B05B1E7C888EDCC1D7D7EABB00520F7ED30738EA72CC3C111E05
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
117E7E66AB85839067A774D4771F5DA8489D041DD3D95C500A7488E9080B33290D0C0E9FBB7A87BF4EE9A73B1D7980F42F07B19B67FA746CCE4331B2E54AA106
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
FF6F1C98D86CA250CCEFABD7ABAE1C70E339D2338CDA4139FA3D0B9137670A8819EED6250C0F199C9CC110852EACA330861DA5F1809F82214D67D4F7A259FC01