@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: 1701299700 do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 44.775
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701299700
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 44.775
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x43C826C926314F09E0A52E3D7F06456C13857987116B2B89DD8E23D258A34E74,
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: 0x000012747D606985401220DDDC74BD16998D4E9EBEC0769ECDD4BFEDAFCF326AA953, amount: 44.640675
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.134325
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
E92F10AFACF53A53593CFD244C0D8A2114E2A2F76825411FFA87D973F0CA47FB2BD3A40BA0CA96A623450B9900E83DDE9EFD53A8D957D9681E793E69
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000E8F8...81A6request_funds
[ 1701299700, 44.775, "000012747d606985401220dddc74bd16998d4e9ebec0769ecdd4bfedafcf326aa953", "43c826c926314f09e0a52e3d7f06456c13857987116b2b89dd8e23d258a34e74", "0x0133e01760f8e5671b30944ce9d52480253381b83bfff2da061965a288e18a9d", "0x708e60c2622dd6bb97046f00f04ec686f314846d", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00006532...25F1At 2023-11-29 21:15:37 UTCAmount 0.25715198 UCO
Previous public key
0001586E920B1AF2CD0F479E0DEA0D67DDD6EFCC9776E50BF4442DF4425FE6C90496
Previous signature
14773B4B686CACD419C45E298EEFCF1A10E45DB7315B15555A63D352D4044FE0FA9D50FA3E80D948D1B6752345456836490132E1B3D76AD4B6548400C9469F0C
Origin signature
304402204EF1B76AA92BE0B711F2570A8AB0C80FA72023634598E8D018F76A8A66F5FF6F0220564F326F32F3C1F87D6578B6E5C9E98130DC1ECC9FFA4F5B5FF023A8958D89F0
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00FD4F66C44E2BF41D43EF24D472B8174EA8032E3E556AEA8E157ABFC45FB163F2
Coordinator signature
DDAA5232DD486FF5C2482F126F502B6C2F54A5600DD6F2D0953A232DE64DE7DD0F9EB496F85A253F1F4964B5EC66BA253FDD97EC7856A478A1A2C625E979B705
Validator #1 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #1 signature
67BECF28352E50050F6B73E1BB40E84F6ECF13CB1A2C22323F2E860C30039E55DA8AA9719BF0CB2BAA4706D23EF177A93B26F5D713D41E74F3704D7651D37104
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
D19FE0ADCD48EB9596DECFBFFD513F1ECE0B4307E4D28F26B72CB61D7412CC5FCC06DBF0E2FECB5D964510C98847D4B5EDB8FA4EEF27D26DD5745D889621AD0E