Type
CONTRACT
Validation date
2023-10-31 16:38:27 UTC
Fee
0.63279087 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: 1698777420 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 >= 1698777420
  ]

  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)) == 0x4C5A7571B8534F082227F59D672DF2311F3253096CF58A7779BC1F55A92B9938,
    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: 0x00008DD40CD42287A3C8282065F5BCA7259AC7014CD73109B570E946A977687C7BD0, 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

    1D3C53664FFB4E869310A6880DD78F0C9492FE27607B4A8841996BCE129DFE78ED37F16E8EDE283B0C35E9FD751CDDF835B7B0DB2CF5862D6EDFA08E

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000115BDCB09308B47A9E6FE09366AE7B3D8A0ABB38967BDD4C7BC44B891005549F0

Previous signature

84C576E7CB6A179B079554C66F352DABD1CF6F871AD74E14A5CE246416DEB84F82A495894FA56F758E24E1EE08E369EC49121C2A8B58E714580E2C2F7AE82C04

Origin signature

304402205422C2E7657273843FD3D7F0D032A7A7DD0DDF8F65CD255988D60F83FBF495EB022020D86CC37B792A46B254BC831E0162F528871CA7BCB36BE792327497408A194A

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00BF38B77DAB10F64E792FD071050A19ACE958D5B1935C61391B591221C75E6776

Coordinator signature

38AE6795B8CE83A9945CCAF7138E931826F0C135AA63F15DC2858048EF7DD621864EA9F4A5ABBC00AF56819C97B83FE8721DB8DE626E40E3E342158E289C320A

Validator #1 public key

00011ED0B570D680BE5ECD58D2D121689DA73C46DCB38A01C6E10D06286040ADE30A

Validator #1 signature

49D82366A592771BFD165BFCFC82E61BD32E9E53C4FA9B3CC1FDECE58D8FB00A58E938A6258C7C1E008D95DB00B38DD94F399460D975BEF4B7E41497F36AB90C

Validator #2 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #2 signature

6481D1E8A75D3F0F94461827987B3CF92BC11E84885ADC3C08E6BEBC49A8264C2FE8BAB3D02FA793676B65C7734C05ED359AF9ECE43E4F610C82DAC9000A8509