Type
CONTRACT
Validation date
2023-12-28 11:24:29 UTC
Fee
0.49368185 UCO

Code (1.01 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: 1703769840 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 29.85

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

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

    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

    A89094E8A069F66296F70C216ED822163B358004ED9C879B80D8A22999BBAAACCFCA843416C4A1E0A64BA38AEB316DBFEB4A63BABB535B6116ADE15D

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001E5F8A2B4C8C8766214CE8193ACC0665E8A4350CCB477581C532565B76D6372F9

Previous signature

4DE0D212CF6756E13DB6E1F40A40048B3D792CB9BD38F6C9B582D2FDDC1E6D56AF1BFDED38D13001622C8DB28DF680CA7B077FB961AA3043AACF565291CF8807

Origin signature

30440220761ECA7197E2DFD62893E3440A6C3529D3C3A176A3321895E95EB48E85E3DA2602200662D44E37FF3ADD3570356C325C094E483767B78E257AF1DD159928D395947D

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0052E5FCC1AE6CFD6C08260392A9865AB06F7160D3044FF376FC2E3DC3B9D9FEB4

Coordinator signature

D1B3984B550D62794103171310474C4285F446DDD2561284A7D50AB27108493FC981F0EFEED58FAC7B541587FD74ACB99545DC6D1162E98372A0D0070B838209

Validator #1 public key

000177BA744AC778DC2D51A1B7C622E7AC4BD1E1AA8DA2D0FCE71BAAB7DAD0E020E0

Validator #1 signature

6BA4108B52E9BD9512295941A97E20761A7E3E82E99F5A33FDD5614CD0E65C9892E196B3E9BD9C45B5AABD93C7D2234C90D9B8BE9E7EF523578A744F7B1CE302

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

E20D0A79241911283E64C98F518D593392CA837419F21D1E044F6778E0ADF1732DCDAE74ED790EA59B829A869106D7A340F77DE313442086725F750CB0CC1B0A