Type
CONTRACT
Validation date
2023-10-25 15:12:50 UTC
Fee
0.66028714 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: 1698253920 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 >= 1698253920
  ]

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

    0267A4F309844FBA01EB1B3C7033F9A9564A6B00D036509511A75E291685B158C54E496DE3C4BCB7EC14250E7B5ABC9E2B062B7C5524094C29982C94

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000127A05D16FC8FCF01373104D2B8168343E715B68452AC12A162D42C918FA011D2

Previous signature

8F00C6B4E84C23F88B5BB107BCA9EF7FBB8FA02400C366CD3E3FCF60BCAD5F5C37FA91D5ACF6B8D36DA1EBA5F85EA7CF062822F48A9A8EA3DDD7685E2A32BC0C

Origin signature

3044022045B2633FBFB51510F8AAB9BD34FF10229D638127F3CD79624ED840B385234AD2022069910E5BF9BF4018A3BBC20C7F541E7E6BAA50900D6BD86A1307CA82ABB51F5C

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

001DC9DA4F27ED889A8D1AB1C17DB9355617012D4CF822871CA0D211EC17EB7AFB

Coordinator signature

E1CC42EBEA9654A11DF0AABE203EB39BE5531D50C200304DD8D3A6FC18D0E66C3CEFC1115D55C1C6971FD8C09EBC70B57B71CDB860A964D42B29C5705835EA00

Validator #1 public key

00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC

Validator #1 signature

6AE2BA51104847B4A9931E1EBA2ACF5C13894813C71BC7EE13387C3879B34D7890ED5D4DF89E4F8D7867947CD72C0E65924DC4376AAC20E236F438ED2C9DE60E

Validator #2 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #2 signature

4217CA1631AFBAE6970C431F5FC5BEFD5F20AE6342BDEF2AB2C912EE05C19BF73CBA0DD2FCBD3A0FAF756DCDFCECB9932840E243DA66101E101F55EB16866907