Type
CONTRACT
Validation date
2023-11-30 16:27:07 UTC
Fee
0.50936979 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: 1701368640 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 1.98403

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

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

    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

    D7C20F43E1420430F49BFAE85032DF76E5F14A18FC50FD7362CCA6463F14B970550EFC908C9E3C1E4E23B8108EAB71C549E0FB10920A2DAE439BCEDB

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000120AB9AA934BCA07AA30734A04BAFC7BD92724A338DA57A0DD72836715C318F4B

Previous signature

838CEE51B86375D2C0CB11D9F729F13A4CE4B75C5065D352DBDE8CDA3C7DE3C159816182FA32D020913E69B8BBB48B35ACC08DC6260D4803A1FCF9FAD57FE30B

Origin signature

3045022100EF3ECC6734101ED67ABEA3F522155606524D81BEE5716D60F8FF71580BE2FE1402203D16A9F37B758489F9CE4617A97F5BEE35BCC083E633E21EDE04B0BD5AEC1B87

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

003364ADEC56001144E864E33863122F978DEE5111E691446AC83DDA49FA8ED34A

Coordinator signature

87623CC4552059DDE15FB0D9B9EACB7B79DCC46166020E1D3828BB6EA719A9EF39CC2E4D4B31782EEE7BE93EF84782A92D27D0A50CEFA612695BFDC8F37A340C

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

9C61CCB933BFC7B9EBFC695A3DBD5956513B4633FC6B748BAB5C7693335B44092A58A4C18E4F712BB7FF3D1EC619B1EA8924EB4F587B38AF85D7E038EC670D0D

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

4D88193D13030323DAD55BADD1B4499B6B74E4CD1AC92F6C030CC0AF02888682C0F6D0B9EA5283816E5D01E51F94F34D85F4F29BC843C55891990E7549F4B501