Type
CONTRACT
Validation date
2023-12-07 07:31:58 UTC
Fee
0.50386096 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: 1701941460 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 >= 1701941460
  ]

  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)) == 0x99129E33CB3FDC387B57B6F381A0DA227342BC91ADF7EBC2FC9EBAE19B220D79,
    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: 0x0000854662F2FF47226AF328EFCE8A16A518F2F9F0225DE5CF5FE431071217474BB9, 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

    73F08E47E558489A64237D583729A3C2333797E01BE526E952D55E6EE40125E6D69DA764B52CCCBE00EDDC8F1FAEBD7894D0C9818D205A83F42F11B9

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00016FFA82B70B3E46BD43804D6488FB3D7E929DC12D651D3723384C2AFDE184E52F

Previous signature

E7929D9A0E6261C75E5C4652DB7F1E46925C6E157C93C9BC6A3A3445F21170E95F5BAB048712A1946008F6C6556040900F8C6842CAF6AD0B2047B9D1226B0E0A

Origin signature

3044022072DAF7150AACAEFCB46D39B6C08D8E039D61C618786DEB014F8F33769CEF8E6D022063BCC2ABAF3098F1FB4C05396A71AEEFF2A56DA49D208F0DC4B4FCC5BD72A755

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0036468EC070DDE9E7BEC45DA85830C7AD8399CFDB098D2FA2DB16CC6E98F69D26

Coordinator signature

40BE3119D6404290D3C26279C72784C87047C58CFFE61A48B5189A943C82D7FFBB469CFBCEBB2A440EB0CBD3BD47F4303B7EF02DE409DD2F88904FA56D1D8C0A

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

73EA6B587C7E361FDD03776887D44D0C291F47DFE53749E43734E38E2D7595CD3ACB46E311CE671B22CA3F3B21E36D259A9FF2AF7E99B3F3CD52E9186F7B0A08

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

35659DBB828696116800001CBF9376A159B9B40A9CA6BD447511E895607CBA000007F4459F6A56CAE3DC03FBF0D6429DEAC236EACEB93BF0569D9243747E7A04