@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: 1700524920 do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 0.00995
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1700524920
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 0.00995
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xE4905263CF35EF1C2B6BA8D472D6D22267BEF086555D344AE69CC406D3028CAD,
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: 0x00000BC0EBA2DBCE4455B46F5E51AFAABA6EB4C7FBA1D4E2E6DABD55DC70F9A04D6F, amount: 0.00992015
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 2.985e-5
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
EE1427772FEE88A8AEC5FB3151BAE7F2C4F736A60F1D485DFA68F78CE35E3ED8263E9141D8A8EDC7B360067D7B41C12A109638263179C31C913F9CDF
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00005377...9DABrequest_funds
[ 1700524920, 0.00995, "00000bc0eba2dbce4455b46f5e51afaaba6eb4c7fba1d4e2e6dabd55dc70f9a04d6f", "e4905263cf35ef1c2b6ba8d472d6d22267bef086555d344ae69cc406d3028cad", "0xc6c52a72f640b5e0f7172c382e6ff7e3c789950669efe2e2bf4decd03c7e7470", "0x03395027ff4992c41af287fb99351b9de43eb1c7", 97 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00008A5D...EB89At 2023-11-20 22:02:32 UTCAmount 0.22928175 UCO
Previous public key
00018B2A8D5A29B3934F1CEF00E44407B231481657F0BE75FBBF3D9C8A94C65B7BAD
Previous signature
49E9DDF504DA4793D580E8E1AA53A829666243CE495A01672E28A75E46E761FF354123F7BB6CEF0322449ED5ECC4C6439B3EE21385F945137F1003B5C4C2F005
Origin signature
304402205D82E932E0DA33FB165629D53E83B40B1E72D8E8C1A5A2729894406576EAD00B02206469FC8900B98319EFB38DF80FDE60210EA9ADDC70E42AC34B0C6300ABAE8EDE
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00AF1A340AC10BF8C3708371A88676515072C7B382526FB079592CB856F412A67E
Coordinator signature
6A4E0A03DE7B56DCF46639C09C50FE906AEFFD859C4206CC023D4711AFA929A5B3D4CCAD99D9FBCA7B56BCF4C6007B9263121ED0EDCB27F361A56C7ECBCB510D
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
F3D1ABAEF93990234081103407BC31B5C07503BB7A9C112D49D07D9E8CF52BC93D9C40C843CAF8520296A792DB5BAA3BB46EF5F236C9B3D59D95BCB66AAF3F06
Validator #2 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #2 signature
36AF7CBF794C6857D07AC40FF17E8A36869885334ABC873A31B32861ECFB4B65B25CF9AD4FDEE122CCC980CEABF55920771D1DDC0099489AA4B79CA3AF686A03