@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) == 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801
)
]
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: 1701852120 do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 29.85
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701852120
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 29.85
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x42F41415CD10356B705BB437B996AC918633674F669CF12E0D588022F8FDA681,
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_uco_transfer to: 0x000092BA2D068F2D89376216B38D2D8D5A832B0C80C0F3A6B79049C8F4E84CF155A9, amount: 29.76045
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.08955
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
22F90FFCFB11666BEC4F891BA18E42A578CD21F1787DFC914BDE46464AFE723B1C4A5613614794B498A20B5154D23D0DF56F6150A569BABFEDA1E57E
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000E2B1...7F87request_funds
[ 1701852120, 29.85, "000092ba2d068f2d89376216b38d2d8d5a832b0c80c0f3a6b79049c8f4e84cf155a9", "42f41415cd10356b705bb437b996ac918633674f669cf12e0d588022f8fda681", "0x71154c3d60d4d50e3ef2716ac7e8ac5c5f09e47a687ea2bbf39afcc810c40e7c", "0x9d5c070046a95c2de56f7de8b9e8315cfa160bf8", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000D452...C890At 2023-12-06 06:43:07 UTCAmount 0.26303197 UCO
Previous public key
0001B848D0D0D18F9547FFBBE0AA99FC6843BD8ECC3FC90CBDD0C2D7AA4CB395D51C
Previous signature
D926B8B939447533EAF692156A631728446E0245CC3A747E2D4CBACC31FC147A184B6857F83F3F3C00E2289D375D796E1A1C302A57939DB92359E053ABF7E004
Origin signature
304502210082CC3C77741BFA077D74B958BC84700C52520BA173891035063969D452AF3A8202201C8C0CA1DE4C74ADB93A609F5E538E6C275FC12F4EFA39ED5B79DEBAC7273903
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00D36F316F0FA9636F4724EB65AFF2DD62BA68DA0C14C4E13DE04877E7CF2FE5FD
Coordinator signature
B216A340ED77DFDA18F58B53E1B45FAA997DBA2A880D9BCF705EAFF04813A1F38C163D0FC341E6B95F1DFAA527C0AEC1B33FE8E440E11F73B1FFAAA24FC70601
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
DFB4C83B8DE546A97CAF46199D2B17B409B63B6730EB548231807CA659AA4A3408763D48232BD27AEB9E997B4E7263E05FA051309177E0758ED4566E326DF00B
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
407EDE659CB04FACEAB25936BA9C81284E0A060AC3D63AF5F3FE5A52B6C0306F631916860F06C6554DE9FEB611EF7D472F15B2D751A694EDDB99EFB7AB459701