@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: 1702049160 do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 24.875
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1702049160
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 24.875
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0xADB8907039B82B2DDBA81A137115660F2076C3F60E923648D8A0482F5492CC0B,
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: 0x0000A6845B1EAF2B4FC32DC8F08147C25C9690601AB893C26C12417B7A64ED822424, amount: 24.800375
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.074625
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
6560922CF6F1F587DB758B665B1D4C24C6832681460DAA9B0BF2327790F6384A32E662DB4089B1F7B9F7CB5C8848EEADE4B74993C247DDF7F844CC92
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 0000627E...8F7Erequest_funds
[ 1702049160, 24.875, "0000a6845b1eaf2b4fc32dc8f08147c25c9690601ab893c26c12417b7a64ed822424", "adb8907039b82b2ddba81a137115660f2076c3f60e923648d8a0482f5492cc0b", "0xd9ad54dd30356282358877661b4e240a0260c72761feacc959b4b8cf38788f52", "0x601e97d7b4af4030fdded277382ff34cde6a4514", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 0000C1E8...0CD0At 2023-12-08 13:26:55 UTCAmount 0.24236706 UCO
Previous public key
000177761ECA8F007D50587B9B24DD351209EEB760D2D4D615260991386555112BD2
Previous signature
55E3CDA8ED51D6A699B6C33E33F6E74BF66929C8031E9596E7828FFDEA120CC8E05912FD4C48745B89A4A7CAC22D17D11F62EE0A79E86E68B773B071BA9FC202
Origin signature
3044022052FC7FD6E3AE17A275BAF43E08A81CE6CB0FB05EE649886BA66ECA988DDAD1FA0220511849E4E5B95794C82C14DA95FAFB8B19E9049B8D10C74E8D3598B4CA16275C
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
00B6CD40DC0DC5EDC481A36CE8A8AF001A870AFE54BDA5B147DE03129589A552A1
Coordinator signature
B5B2D4C53CFABEFC516B115DAD54A80500698D1F1AEE926F441350543B07905AF89D4296A82F3AEB11220AEDF170DD88B45EE1C898A73FCDE910BBE336DE550A
Validator #1 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #1 signature
F610E3A4B6743D5A3BF04B91ED109B443E0399E7F48C7E2C91ED65F67C4DE9E3EAAD0EB47C154887ABC7C31C3CE8B8C458E2ECCC2B8118C4A6C82DE72045080B
Validator #2 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #2 signature
D1DE3A2CD8BC56C683008479E7F284649B98A32B039F22A3F6E1AD4BD073EF76F7A0AE1CA7F70AB5C21F9DD817266E074842E37E79F0EED446FBA9749E105807