Type
CONTRACT
Validation date
2023-11-30 03:01:23 UTC
Fee
0.51341997 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: 1701320400 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 79.3612

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

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

    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

    0B3869B22409ABD06A1446DE70E443C4E5CF80E1D14145FFE3C9F063E9B688DBC9CA71DED405CD47BCD9D60329DCC9E4F146C8875E6A806BF8F1C285

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00019F71E8B74E9E0EF463831510CD0619A8795B9572852D4C00C2D608C592FDBA6D

Previous signature

DB8EBF206DC6FDB4D4D409DBA304A71722564D479C7B2E400F2053E1F9B4ABB7D73D8AF00EF2A4A8F87AC80CDC1FAD6C227EC95C965E04B13DA3453FAAE38608

Origin signature

3045022100DB8BD9DF6826FDCEF83EC61569C156D4D90B134A5F2E9F9F04BCCF18FE661B42022026F6247975C01FDB2FE1630C514E682FB28CF17F65EBD192617F02883F4ACC3D

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00B6D945960CF4E1C852E75F898F68E87EDAAB838200B6C35C3433ED1310DD1A71

Coordinator signature

5FB08E07E64A651B8E316F2723D02DA4B908DDF53B7485ADD5C3A35B2D2EB8115D357BC31AF7C521C22DD7616979F548144F8F21EDA016AA6DA98825A0D4BE0B

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

4D489C32B0258B966DA3F2CB88610A6EA1EDFE516A1488874A682D36EFCC8E94B913D91E768B860245B913DAF9330769F772EB662E77BEF85BDD4DA290CD9700

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

943834DF1B3F740D64B6C2532DA7FC13EA657B8E231775C192C9E857DDAD3BC8EB4CAF0CA5CC8ADA1A3F87E7607801F2C159D1C2E4FDF65CC32AA1EAFDC6C908