@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: 1702109880 do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 2.189
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1702109880
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 2.189
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x4B7689E80D33B6FF5C5907E433D47B3D965713C02F711988A966196556DE0D9A,
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: 0x00006205EC2CC3B763AE9890AAF29B505C7FB96395DF7E129924D72D0548A8E57436, amount: 2.182433
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.006567
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
12D46B09ADC15A3C60403D53264A539013CA4F1233E1D2D752D6F183C9F4FE7DC208C5DE272FFB1D68DDDAB36C324DBA12F86D01E23A4890861844EF
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000182D...1ED5request_funds
[ 1702109880, 2.189, "00006205ec2cc3b763ae9890aaf29b505c7fb96395df7e129924d72d0548a8e57436", "4b7689e80d33b6ff5c5907e433d47b3d965713c02f711988a966196556de0d9a", "0x16d09806b66552a0b4b0658a9c97ac38c17bd334fa37e41b53f318053c9b7274", "0xc90667686217e81068e9779a5769f3c8217281dd", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00000DA2...783FAt 2023-12-09 06:19:16 UTCAmount 0.25337989 UCO
Previous public key
000158D16F5D612D6EA31555F4EC1083EA517348CB80568A359A1964BEA23DC14455
Previous signature
9142A9F7DD22B7E2B066F261911306FA3D3F797A85078C07514D49792EDC5D36BD6E904E6ECB7BA35959FD5964AABB731C13EFE7ACC77E49258CC4F7FDA87F03
Origin signature
3044022055B9F94F8DA831892C1A2BE60973899622C5E41861BEF15992E661F5D61421AA0220439E6314D3630CAEDF2918334481998B6D5AA76DDEFC9201DC2626F5C5B2BA0B
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
003B83DA58CB78DDAEB858908BE11882286EC8CE7ED24D2C74C9C383A0B1C7E613
Coordinator signature
5297F860992DF086E0DD2C893D7931DC8618D1A57683EC4B6C74310E445B453712625BF81F2B3164BAFD5CBAA34F1224A1439D9D32AF56FCDA6012FE05EA540D
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
A70D51E0B9EC11DA051C42BCFD3AC3F72A1C78577CE76FEE5A3BCAADC8570308AA35E2AA00B8DD18A5EEDE349E7E19D242DB3A794E2A628A629BA251EB74BD09
Validator #2 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #2 signature
D383EDCE506876A8C5E12BF77BE5B0A6A037A3764233168D0385BAC32161267DA16F186F8C438644A258B764182009A7DC17460CB14A10324828BD8E797BA90D