Type
CONTRACT
Validation date
2023-12-11 05:27:09 UTC
Fee
0.53736237 UCO

Code (1 KB)

@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: 1702279560 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 0.4975

    Contract.set_code ""
  end

  condition triggered_by: transaction, on: refund(), as: [
    timestamp: timestamp >= 1702279560
  ]

  actions triggered_by: transaction, on: refund() do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 0.4975

    Contract.set_code ""
  end

  condition triggered_by: transaction, on: reveal_secret(secret), as: [
    content: Crypto.hash(String.to_hex(secret)) == 0x8B6F93850EED35590B511EE476F7BD0BEE357687A87CB5A9BFA598802459AE6B,
    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: 0x0000E1BD3ED17C87EE4A7354501DBCEBD07D9D927499C2958B0944F97262BBE892B0, amount: 0.4960075
  Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.0014925

    Contract.set_code ""
  end

  """

  Contract.set_code next_code
end

Content (0 B)

State (0 B)

Movements (0)

Ownerships (1)

  • Secret shared with 1 key

    Encoded secret

    42554160434E8B267D951BAEDED247AF349385759B187F0D53641564C28754ECC690F0690F5325D968ADB4E63E8D9D47481F1659B5CABF776FCA28D6

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001CEE12854FE76F5D173BC554F62E90932AE89B13633888F8555517ED7D69BE6A0

Previous signature

7DF46CE1A6E90D482B01934B65F6209C107CEC72F38822810E4BB75AE142A1EF75DBC5FA55B1BE563B4558A18C276AAD387624E5CF83361D5BF518BFA0FE7E05

Origin signature

30450221009F5FC1FA0BBF1A820303E6C4DE8BFF76B9F42B5A616138D4FD97621CAF393E5502201D9149B2630B5330937FC79B25E42319B0196B1227A381224199390692BF478C

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0018BC7A50F8E193206174E29880F647053FA215C937B3D52AA4FDD929B8343F99

Coordinator signature

DF4266CDCB24B921C111D4EA47E43ACFE56140639C8C3C57C1E7E92BC06AEED8C5681D3972E58C1CF0B1EDF7849AA45A85FCAA661E4C5CA509FD05AA0C5B2E0C

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

01C823E9ABE2E11F90A8D02C96942AB7C12F75BCDE717E4B5CED63DCF9724326AEB212DD328E247F6249F7F5E628FEE26175E7497B851A772571F4F7A60F6C0E

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

1E681AF260DAB86268912693CCDF5624A42E75833ACEB5FCBBD4E6AEF47373C349871BB9072577AB1048B32B12C456F72522CB615F706992DFB241798122D309