Type
CONTRACT
Validation date
2023-10-27 09:53:11 UTC
Fee
0.66711719 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: 1698407520 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 0.00995

    Contract.set_code ""
  end

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

  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.00995

    Contract.set_code ""
  end

  condition triggered_by: transaction, on: reveal_secret(secret), as: [
    content: Crypto.hash(String.to_hex(secret)) == 0xDA2D27ADAD15C882AB66F1853B99B7F6E076FA903F4AE6906B3946FBDE186A85,
    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.00992015
  Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 2.985e-5

    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

    E86D19CDA075BA51F7589DAA6578A0CBF0E1803FCB98771F80AEEDE4C49A3630F52AA7BB5AC00A4E14D7F5D6ACFCD39ED30E50F81F3390A81487319D

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001DDB0464C39E40DF12277BA8B04CE015441EE0D6F6058769CE3C7D511230B788F

Previous signature

D434302ADD4519B9BF4A552BC74E834B37EE62F5A77B033AB0E41C714009CB8C2D1D939C3A41691A71D65C12C63147125A3DE54D06B502A998AC19F21259DF07

Origin signature

304502210087C9D868C68F67F1691BCC81D0444AE02EB1DA59FF501A9089CA2E0AF04F540D022007D9569C9C91B82E1295BA2173F5194D076F6381821E6BD4F89FD4C39A56967F

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0043127FCF9F3EEA309ED58EE1C694A32645102768DCFC1B4CD43AC0D959981DA6

Coordinator signature

F5B428D962C0CFD32D9CD373A7765BD0851FFFC30958AC685DAE18FC149DD11F4C82AD09AEE6D4924DE91C7EDCC0BF0FA35685A07B2430AE8818B1EBB7D44009

Validator #1 public key

00011ED0B570D680BE5ECD58D2D121689DA73C46DCB38A01C6E10D06286040ADE30A

Validator #1 signature

25E5C07EC3E3D07E9493EA271A9D6FA5018C2F290E048768124FF54003658F6861C26236FA8FC3F3F793F15F906D29AD8C3BBB16F327048EE55F9E67BBD7B70F

Validator #2 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #2 signature

EAC4418134E144EB7578BDDA773EB321B91FD09EBE7ACCD3863021CE49DF0F0A1E0F9B5257A39BB7203B1F627E4734243830FCD5630CDB917396632A817BD103