@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: 1702760160 do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.04975, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1702760160
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Burn the non withdrawed tokens
Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.04975, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xE14DFC920A3E025C48784C0395AEC720ECEB8A3D6E16216DC338E5B217DE8221,
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: 0x00004D91FC38AFC3F07783D5D97D7FEE42B3DCA005FCBC1CFCB57BA65EB542D8946B, amount: 0.04960075, token_address: 0x00003DF600E329199BF3EE8FBE2B8223413D70BCDD97E15089E6A74D94DE3F1173B4
Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 1.4925e-4, 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
0F7A7D14C9B0E97DC4385B4012F6BA82602C4B01E31716939B7C981BEF28F2ABA1B7B1541D0AE2770BB67B3C19A8E3F42CBF21B416934BAE3292152F
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000B0F9...97C1request_funds
[ 1702760160, 0.04975, "00004d91fc38afc3f07783d5d97d7fee42b3dca005fcbc1cfcb57ba65eb542d8946b", "e14dfc920a3e025c48784c0395aec720eceb8a3d6e16216dc338e5b217de8221", "0xc55a51b3931de8cd50ab1564a5a4b95eb41164cadd06e8df562b282f5b6dbbc8", "0xe21127daf2c9139f931165394e162b0350ca9849", 11155111 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00009378...D8D1At 2023-12-16 18:57:09 UTCAmount 0.42738063 UCO
Previous public key
000112ABD19F671CC4C0CE732F71E036308C047CC06D8740903D32BF2F564161CD63
Previous signature
D61E29321AD132D3B1E2A89CA791485DA93E3ECF1AF6AAB3379893C96B0AE48762EE1E726FD835139329C8425346C9750F6903AE2CF00FCF420F17091240960A
Origin signature
3045022100E82C7E3D5CBA6E94AE8419221AB225EFD52606AC1F4A6BFE39B6EE14066C76BD02204620D926F35B924D5D65F5F20684D73C6CC8E5B2BE96487F8DE680E8AF9ADAE9
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00D12A397AB91FDCA0C750EEDDE03C46BC9DF6E79EBD65F2E16F48ACBF6D3CE7E8
Coordinator signature
25C6C23E8A636B566E5A8DF935DD437C12E05589DF531D13D5462BBB8F098A6FF50A3766FC0A4A81BFAB2C314B3A5F5EAD8A18BF8E47755ADDE25A11421E1E0E
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
2F96BB915E7116EDCB6421E9EA1261AB5047B900567354EDC443B13F763C874CEF2845BDC514E945591BCFB62B119C8A584FCF6C2E1E0772E3B449E32C260503
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
D5E8C643F8EA8C5D4677D21E741AAFF489FAB04BCFDDD5E3522F411F10CDCA7AA23F5E2331EA55E8D26968E5A28236AD22E2925E91A68EA194AA380E1BEA920D