@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: 1701457020 do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 5.97
Contract.set_code ""
end
condition triggered_by: transaction, on: refund(), as: [
timestamp: timestamp >= 1701457020
]
actions triggered_by: transaction, on: refund() do
Contract.set_type "transfer"
# Send back UCO to bridge pool
Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 5.97
Contract.set_code ""
end
condition triggered_by: transaction, on: reveal_secret(secret), as: [
content: Crypto.hash(String.to_hex(secret)) == 0x94F572E3D588DE08820743619282F85E467D9A7C1291A053F355B057E1E88B82,
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: 0x000045EF655A0015C0746F2A6A13E14778DF5954FF4F7EFCCD15E1AE3B67CFB9E54C, amount: 5.95209
Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.01791
Contract.set_code ""
end
"""
Contract.set_code next_code
end
Content (0 B)
State (0 B)
-
Secret shared with 1 key
Encoded secret
1809ECF67350E91AF163C4F50A523FDB8B705B66002897D50103FC2358B363D0528F2B0BC4DEB14D707E24714A0FD0C5F2B24F3C76EBBFBFE8F36F5E
Authorized keys
- 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F
-
Resolved 00000F6C...822Drequest_funds
[ 1701457020, 5.97, "000045ef655a0015c0746f2a6a13e14778df5954ff4f7efccd15e1ae3b67cfb9e54c", "94f572e3d588de08820743619282f85e467d9a7c1291a053f355b057e1e88b82", "0x8b6350fa9ab319bd4ea0f3f914bab6832cc3e72a1cde9b2f82f785840fef1e6f", "0xfaae214fed3949452b174880e4d251f76629fb46", 80001 ]
Inputs (0)
Contract inputs (0)
Unspent outputs (1)
-
From 00009B77...5ADEAt 2023-12-01 16:58:14 UTCAmount 0.26353179 UCO
Previous public key
00017B66BA8741EBA0B4EDB7803453E40D938537697E78537075E0425B712C7D3CD9
Previous signature
33BE94200019C4CA880A5C6CE47397D7471DBCD78C737445534401C127741533D892AD53A07944F31602D31A925122264DB76BCF723C172A772D100F51C16A0F
Origin signature
3044022027C93228B77C377D83658CFDB5F1B80026CB4ECD1BEBAB22F785F83AEB4FC53F0220396589FE64AD52AC807EFA2FED91E215F21899916BE28B421EE55E73D8FD1A4D
Proof of work
010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6
Proof of integrity
009214EDCC60CEDAFA3BB49EE39C32FCBB237A597CFAD081C7A789034A83F96FA0
Coordinator signature
240C841015451D6596243848DC2E3769C93B62F2F39358B4A9C131370969232B6A5DE494E702511FDB423F3E75BCB29238D1A7990B40BF567A15686EE7176400
Validator #1 public key
0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3
Validator #1 signature
E0534615476F1E0CA07C3241137CAE57740A6A28602CC2832CF53DB08605FF376796ED5E7A6DE5EE12CC3D146E0D5B4A2982BF1BE93B4610E2171FBE722C8805
Validator #2 public key
000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF
Validator #2 signature
0FD464542D36DCCEACDA2A6342EE0801DD5E6D0465E8ABDF27F5CB8EBF2CCD5A99EE6C704F02DE885D7194E5C5E824B71BFD35A4FC90B5057EEA6485C4DC740C