@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: 1701371280 do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 9.92015
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701371280
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 9.92015
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x2E26F9A294FEAAAF8BF73995AE2BE80D4029D0CEE5C1598F4385D36AC0F103F8,
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: 0x000044DAE02EB037F0275BA1732C59121260DA964D75869F95018DBB2DE39489FE91, amount: 9.89038955
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.02976045
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
A646DC4B8E54B7C71916AA0D34DC720FED294199E1C95A46304BAC46660EAD265DAEA29177D2A9F060D68D3F4F47B5073D6A92B9C80CC8A6FCC98A45
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000B298...829Frequest_funds
[ 1701371280, 9.92015, "000044dae02eb037f0275ba1732c59121260da964d75869f95018dbb2de39489fe91", "2e26f9a294feaaaf8bf73995ae2be80d4029d0cee5c1598f4385d36ac0f103f8", "0x40b8f4813cef9eb7a6614e656a8c625a14904398813041f8fa7d2ba553fd98c7", "0x78bcf40d3e6ceef19c034c9f3cf8658375125538", 11155111 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000EEF0...6A35At 2023-11-30 17:09:00 UTCAmount 0.25416053 UCO
Previous public key
00010649D73D4D0F4FE9D9255FBE124995B7F0CCA3175B955D4A90F7F3D59D4F52AC
Previous signature
0844DBEB8EC1D5A508E568D3F304C57F04E631864EE641A21D9436D399471461F3586E535E38080980BD283C3D6F4EA76DE0EB547849811F46FF2968656D0307
Origin signature
3044022078085B4CB1F33CB1CE70CFDFA5C57E310A8E5C95AEC36154174FCA8E367728010220791B6C78262A10D697675ABFCE6FDEAC3489C1A5F0050F35BE92640B159920FD
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00B293EA37DF491F2ACDFE3E5D622A132CEB1903DEC9524DBB16F21E6D0DB61F04
Coordinator signature
84CA334D3A69E275847DC834ABB9D78D4EEE589C76D25E7F87809E65FEAB0C04D0B072F0957E6ADDD1282B9BD1840A10DAD1F21B83ACF908661B2DF11AD4D205
Validator #1 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #1 signature
3986AE17AFB83F80B8083C64D69CB8EB997A63729E39BB8E6793069B1F0FC9AA0C6F3E4EFA42F8E063674FCD48E0D22CCDA8C39680266FE216E75FD09C2A0302
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
57449D76FCFF4035D65985C217604AB0F75790DFB69081207E09600DCDC8BF1E6E4EA22696CF62D2CEACE9B7F9F6BE3B26B2DA345A92794357D339F849CA5C03