Type
CONTRACT
Validation date
2023-11-19 08:19:01 UTC
Fee
0.45201322 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: 1700389080 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 0.995

    Contract.set_code ""
  end

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

  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.995

    Contract.set_code ""
  end

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

    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

    EF6C1009A859EAA64FF9BA5EC9887547C32763F3BFA05971019EEF96F7A5E7747B334F6F9E9F735D9566BD0C76601977AA89C6FA778D41B2555AA492

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00012CC5F623744A783EA877223C950B87D1311C1E2EA9902B65736F7D5105FA9187

Previous signature

28C8A3FEF810C636F622929AA9C77A12372DDA21300A7821C53F6548D7119D5E576CBCF3790AE44CFC0B5E12870F96BD1D0E1D428C67C3858B743D46BB0AA907

Origin signature

3045022100B979813B71E419C65876C042D7C9414C3611EEC99A40A2103BD7D2911CD63D8E0220620C3B47F57CEEA097919166C6AD4647AF00F07E6C9CC32CBFB126C27A054C7F

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

001C90414C2B7A288D1E5CE7AE95CA866DCE594AA0988909EB8E380F43BBF8D457

Coordinator signature

C12EF27C68262F65896C5B3BF1BBF06E2F13B8ABC1F56D34313E4C2A124A8CEF2AD59FF0083F8408B99262E51AC9C6AB39D4A9E85BB4CC2697ECC9D01FD4BB02

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

9833E11C35E5EB1530B0486EDA7B700CED0B2F94C000BBD79123F67D293CC7FAFCF9FF8FFD130429E4B93809AC468893DFAE59FE3A3926B629FCE9D85173FD05

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

135CB6E7D979F0853E2F1E25BA699CF1CE1C8FB83C386385484F43FEC670AAA8B80AB2B27201F2A105DCBABA467EDB6B1642FBA15A440E50D80AF2D71227B507