Type
CONTRACT
Validation date
2023-10-27 09:56:00 UTC
Fee
0.66661039 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: 1698407700 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 9.95

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

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

    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

    31C23A71A4A880FF7DAC3FA457F1971FF8639AB16B24D3A1F3007700A6D0264FCF46535E59CC43C668656695CD6F5E616974102479BB9243084BBDDD

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001756F9EB76475D07E514356936C55B5CE2D17C33F33C32131736E625217F3BB72

Previous signature

8B9180D43AC5AEAB31A3F1FB40C14F5B8818AC9CDA35DFD0B8A6B06DD7DD442CF160F4C9EC7CAD82692354B4466807385B2B2C9635249681A487CF7011B91905

Origin signature

3043021F5B704491C661C5D35F17DDDBCCED4E3B018B77E05E8D49BC10B1684A541CDF0220352E065B4720D2DF0A876B417D65A6BBE1645EB35F70558DA085E221F6585C85

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0091E34D1D13A1E0E5D401A7E6E99F45675EA649FF2A256645E1DAA7FB3BA08868

Coordinator signature

9A44AD563E6EE1AA929DBFABCF7423AAA82FD33F1A063E8B2ADD9730452135B8551C1E60DF7E73B5E46C4691644909C55A4DFA40BF3284392AF4307C50809E0D

Validator #1 public key

00011ED0B570D680BE5ECD58D2D121689DA73C46DCB38A01C6E10D06286040ADE30A

Validator #1 signature

8D723F4912A8BA87FA6F1A28B036B2A2ED10BDCFCA57A84E778065C1001F2EA2AC65B521B4252E243C9B86859EEC5EF8D1C0DCD3531512D381E354089E29E80F

Validator #2 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #2 signature

C035E20A1119AF93C891DFD93AEFD6D9578F7B973B3B4A1BC69EFAD8E9F9A0882DA8836004D4994E2F19E741C2D866224A5FB46970E2024FD8DB332FE380E70C