Type
CONTRACT
Validation date
2023-11-30 22:15:12 UTC
Fee
0.50119031 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: 1701389640 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 110.445

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

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

    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

    0278EAFEEA04F164A0E74EB1363BC3CF09C8D909C501C46FBC750914EDAD71EB8D2270A668254430205F98CC8F956FAF7E9A19C9A4DFCB37D5BF5BC1

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00019CFACD801D61EA8530BB88C088A414287D52FD02E406232057BD0A2B700EB548

Previous signature

6BB28D88F49B62CFDDB6D023F507104DCA33BE0D78C6485446DE555646FB3BFCAAAC310BE7548FC4AEDC8A43E0BEDC58D83B91CB474F8FA5BA916099E0413506

Origin signature

3045022100D83E29E26A0A112A0E8C57CB75959DDDA8A89A086579BCC6609D331F7E6DB4A302202582FF853FB47BD42F96374F97F80C1890BD00456AD86FB4DBDF35E4E93FBCB1

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00225A02681BA496D7896F4893854538C1A408E97BE8F85936F00585749CC17513

Coordinator signature

3545413A28CC4A32C018ACE5EAECDF9F3BD67F3664EA43F7A223C28F39B02714823FB9B21FABB52DF94A377918DA78015A3C1C5C3FC5C797D8D812622F48980A

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

79A277E5BF8F7CAC0220D95A6C53A89746350D8073F571D2C14A0BF751E46FDCADE997899584560BD66310BF0B12950820BF51AA56C18C567E48CFDC1776A003

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

C948D99AF48C547E4FB13C715A6B66BD05D7A5ED8298AF0F10139E2FBEEB66AFA4B1C9FD6EEB4E3ABCD8CD8E63EC9FBF45DB3E626D403DB70C6567253776330D