@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: 1702144560 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 9.95e-4, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1702144560
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 9.95e-4, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x529A18E2C53B2F78EBFADA7893E671C3C6E5D6061EEF5DE9B5975ABC5CA8B94A,
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: 0x000066062AE51C8EDDB115B895B4917CF9A25F20A0CDAEEDCFC62085AB197F6B48FC, amount: 9.9202e-4, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 2.98e-6, 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
60029B925CC13095164DEE8C592FEE48BA22859167249DD8C67476C79353E67BE50FB85BBB8A42353F9BCC6D413D53DAFEC321E6D8942C154062D352
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000A6CA...CB16request_funds
[ 1702144560, 9.95e-4, "000066062ae51c8eddb115b895b4917cf9a25f20a0cdaeedcfc62085ab197f6b48fc", "529a18e2c53b2f78ebfada7893e671c3c6e5d6061eef5de9b5975abc5ca8b94a", "0x1e2739ca80da7587cc637a1c5cd902cdd837534cde1cba35e11d4bc92123c9b4", "0xf069dfc4bf2911370d442617e7862572a87ce454", 97 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00008F86...A6F5At 2023-12-09 15:57:11 UTCAmount 0.35621083 UCO
Previous public key
00019A28A92D4C4F508B521A687D27DAED9D7014F55E074E8F87BAE2FC8827E704F5
Previous signature
2D97656E7D66672664DC6F28C6C73B8C32AC93F67C7423504952ECDC77ED02002F58344B2269D3A08B7F97E3A732C901F64336129F685E235343043372B83709
Origin signature
304502210087F36174E70C00DB4165F078F2B6736954BE30B1D432DA24787827631E18708402205AD0F265E1BC1365EAB902CC79A15330FA7F05764F4FC139614B62D12A5B26D4
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00D21D308E3779115372AE7A7EB42331B32DDE0A46A17F5B6293A5D5A675CB3F6E
Coordinator signature
DD9C3638197C91F82F0AFED5041E51124AC4D9CBB29F95676FD3F52A7C9E1A60A1ED8D65BFDF3F24D395F2F6062AA3EAE4682A42D544DC3CDC5A1456F3E18103
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
CB5C5827790E9AE6E68B5B4861268D4707D1294CC2215815FF233FF2A658171D9ADB21E28B4170686CC750E1F40338FDDA83609791904A97ABD02B83A4E25F0C
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
6BF10CF6ACA1ABBF5CABEBFF49FC98FD55EA161D05FD74EE78B1FE585AF6D6A5839B4B3B957444C5524F826CF24E868E816E8B0FD23395DD0E2A35AC770C700A