@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: 1702238220 do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 228.85
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1702238220
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 228.85
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xA6CCF107096D3E156B738216B4C34D3671C10AA4FB9CAEB9CB7AF50C78CDBD38,
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: 0x0000FE7C0037D8E66009E288E9F36B199B5C298B77FE607E8A7DD618B13AC007C34B, amount: 228.16345
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.68655
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
3525EED76625DCD91229F4DC0495256C10D4A870B053F7E5BEDED68966456A6FCD71A12C0E69A42E80D69535333735A9DE726C2B6EE3AE86E8B507EC
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000D085...7AC4request_funds
[ 1702238220, 228.85, "0000fe7c0037d8e66009e288e9f36b199b5c298b77fe607e8a7dd618b13ac007c34b", "a6ccf107096d3e156b738216b4c34d3671c10aa4fb9caeb9cb7af50c78cdbd38", "0xa0621c984ccdf98e3d89b1d1ccdb0e9cefbef98dfdd9b9792d52dcb44ded902e", "0xd2dcf2b9342fadbb1f1b7709e153778dde9a4873", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00002D50...E247At 2023-12-10 17:58:52 UTCAmount 0.26243774 UCO
Previous public key
0001E803648948CC0942BAB285502F2626096591F1906CB058DF87844E3954F968A3
Previous signature
B126BBF27318A9E02AEABA882B19F6F2FC180F02CAEB3A89CFF150D57B61410EA6A31E97C25888BE37EE63D8BF85BE32BA9C1179C7AD755318BB2D8B440E3106
Origin signature
3044022017DDFF5AAD755FC67C94E663E771FD91B85C06C1D38AA80DB64F068B6EA167CE02206FFCDD182CE7C3BAE8900F2B264479BA1F20797B5C6D8E9231CC5F5569466E79
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
002E1D6BF16093C38D5527E486A78DF4CFA23FABFC842109CC88A08342F3AD5E2D
Coordinator signature
6CA0C47E390EC3CF6FA0DE77EDD8196CA104CF7AE356A018C1B103C2D1674997238084FDE92A0D085FFC95C8D6867D9A77EE3053FA3108400397E8FF9EC8EA0A
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
FC16528AA9649BAE7E5911DA047849BBAB0CBBEFB6656844D321A580998F8E9281081BA77C2CA0DD64424426C80E6BC8E382B0C3C655541DFFB3448294904D01
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
5CE1051DFD3CED6B88BC36DF74638942B16CBF17CC651F3913325843E824E213AEAFD6B395F41B3353CF9CDC787A103D61BEAE51E94D2837FEA2D17940BFD105