@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: 1701347580 do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 3.98
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701347580
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 3.98
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xC91FBDDA681056C45F40AECDB02AA1E28CEFEDCA3385E34A17932C04F11360FD,
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: 0x000079E07D373D5DD653A6F406D38890A6EA8DFE20708C323B3B576AAD469DCA9984, amount: 3.96806
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.01194
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
BC976A72403312E118382E3EC5515198E09C49F2BDBD06DCF492073D9A16B75E625A4C097B88FF5A1CD38D6932943F5570263D4CC6E2C3261C3CDBB7
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000501A...0560request_funds
[ 1701347580, 3.98, "000079e07d373d5dd653a6f406d38890a6ea8dfe20708c323b3b576aad469dca9984", "c91fbdda681056c45f40aecdb02aa1e28cefedca3385e34a17932c04f11360fd", "0x84a62babc464863d7a1b0a79fc65baa0ac04f9f816ae1666d129d3f44b3279c0", "0xfd1d33bd735e53e2724af2cc6995f66fea62a208", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00005696...0B6CAt 2023-11-30 10:34:08 UTCAmount 0.25359928 UCO
Previous public key
00012B844B1534FF30AE846EC33D9B607EEF2AAC4DD42C33D50C522E5B3A651158A4
Previous signature
AD53BE292B4D68A228EFE27F8CBA9C2B43042C7114FC4C897F566C9CFA38638E26D39208E87F90F7B4B03BCEB0F6B0594B9CA2B12C0B0AB754EB9520DC779208
Origin signature
30450221008B96740BE0B3DBCC750633E37BACC0ED02369EE962273964E0DFD875B94F8D9F0220198D3F3EDEF99B9CEAAF6855717ED138FC5CD80317059F5C582215B4B5990AFA
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
0005CDB26FF6BFA7CD42F7BF5AB763C1020DDC2B2AF43DB55BBE047D86A6A2896B
Coordinator signature
16E4665A1864BA71A0356BD11C0C8605CF0BF63C875FD642A869B2918D5E7119276DF2953129B5F369A85EBD80582255BB932BEB38CD1EF6E2AB262D88F46F03
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
1CE3839788D34CD5C1A9CF56B7E1B253DFB7191FABB950232D063738EB1E3E3D3568F75C539227FB7774FF56E838AE9BCFE82AD0443D07E5754610C0DB958506
Validator #2 public key
00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947
Validator #2 signature
46C6E19741E5A78EF0BC24C62007235DD159071737EF74FA310B8D7DA67A7D21728078B31C584ABAE99000CD49477A2B23136419C7E0E08F7D8217924B802D06