@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: 1701999300 do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 62.685
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701999300
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 62.685
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x4CE4A059C326B472E42C319438520961DF0BE717B395157D5BC7869A83B11C6B,
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: 0x0000DF6477CC7E206F43C4D36CB5ADD35BE5C54F29ECE86A4A34AFF5F3B7D6728A9F, amount: 62.496945
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.188055
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
B554D53392CECB4D739B2DF61072966B31F3CEAF5F0674EDDEB57662A198BF534F173F6A34ACE1096CC672CF1EEFBF075862BD0987FEFCF1BA8EE695
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00000F02...17A2request_funds
[ 1701999300, 62.685, "0000df6477cc7e206f43c4d36cb5add35be5c54f29ece86a4a34aff5f3b7d6728a9f", "4ce4a059c326b472e42c319438520961df0be717b395157d5bc7869a83b11c6b", "0x72492852945c88a6acd9db889aca7c6e6c21c6414481fb3dd9ef4a50e3f862a1", "0x6a258377db71c72670cd8b45f527db8d86c4f513", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 000019F1...2616At 2023-12-07 23:36:50 UTCAmount 0.2411101 UCO
Previous public key
000156BE69D827EC72013437F018AADDF92E15235B3D92BC319FEB29A317BDD0CC5C
Previous signature
190120429DAF335F7405C16CFC970FE152F05A13F96679473E553F0C7AB0A3A719DA8FD083DACF208E7909626ECC96491ADAE2ECC0759F12949677D4A8B9ED00
Origin signature
304402203C65E0C3ADAD022A282DCE7DA2953BC9AEC8EC8896DA51D7993D4B0166254820022078E8FCA4FAF05809971B09AA74C747DDD520EBC12C56AB88536B55BECE474B8B
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
009F8355096319AE922D50A062D39362B9E05E109A78C3018097565976B78C868B
Coordinator signature
37EDFB81B453F016CD75F37777941EFAF74BBFFB6DD8B5550CACB96707DFE2EFA5B3FFA4D1AA66C8AA1D6036F441CC7F8DBB0287976F7DE325CAC02B4E0F5001
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
B11D7C2C33234402AEE9E37D080E8B98D6ADA41E921E5412ADE294AE519D1DB869C779F509AFA100E32A4ED7601FA2D8FE5D4FC94148229C5C202935BFA3310D
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
E465470B10B99087A2DD59BB6911026699F67B0B7DD33F3B4ED8973C45D5C70B47C7390A0CDF496B30CFF5D225A014491241A1EAD7AC9EE49A22057FD17E4C0A