Type
CONTRACT
Validation date
2023-12-24 07:04:46 UTC
Fee
0.21698173 UCO

Code (832 B)

@version 1

condition triggered_by: transaction, on: set_secret_hash(_secret_hash, _secret_hash_signature, _end_time), 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: set_secret_hash(secret_hash, secret_hash_signature, end_time) do
  next_code = """
  @version 1
  # Automate the refunding after the given timestamp
  actions triggered_by: datetime, at: #{end_time} do
    Contract.set_type "transfer"
  # Send back the token to the user address
  Contract.add_uco_transfer to: 0x0000F25C3DF408399FD5CC26D5A53C4081F6D6600B04B5EF4E41836D384F8B84C772, amount: 10.89175225
  Contract.set_code ""

  end

  condition triggered_by: transaction, on: refund(), as: [
    timestamp: timestamp >= #{end_time}
  ]

  actions triggered_by: transaction, on: refund() do
    Contract.set_type "transfer"
  # Send back the token to the user address
  Contract.add_uco_transfer to: 0x0000F25C3DF408399FD5CC26D5A53C4081F6D6600B04B5EF4E41836D384F8B84C772, amount: 10.89175225
  Contract.set_code ""

  end

  condition triggered_by: transaction, on: reveal_secret(secret, secret_signature), 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
  ),
    timestamp: transaction.timestamp < #{end_time},
    content: Crypto.hash(String.to_hex(secret)) == 0x#{secret_hash}
  ]

  actions triggered_by: transaction, on: reveal_secret(secret, secret_signature) do
    next_code = """
    @version 1

    export fun get_secret() do
      [
        secret: 0x\#{secret},
        secret_signature: [
          r: 0x\#{secret_signature.r},
          s: 0x\#{secret_signature.s},
          v: \#{secret_signature.v}
        ]
      ]
    end

    \"""

    Contract.set_type "transfer"
    Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 10.859077
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.03267525

    Contract.set_code next_code
  end

  export fun get_htlc_data() do
    [
      amount: 10.859077,
      end_time: #{end_time},
      secret_hash: 0x#{secret_hash},
      secret_hash_signature: [
        r: 0x#{secret_hash_signature.r},
        s: 0x#{secret_hash_signature.s},
        v: #{secret_hash_signature.v}
      ]
    ]
  end

  """

  Contract.set_code next_code
end

Content (0 B)

State (0 B)

Movements (0)

Ownerships (1)

  • Secret shared with 1 key

    Encoded secret

    623823033C3686DB80277B5BB1C0C057085B2D16248426F20DDC6A9D46B19713ECD3A245F558C51A824365BD376BBC8FF6A57DBE4393A90E68E30684

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001C79356873BDBA47C88F9FE6EC6CA54A2DC3C3B6EC8C59BB347F0F79A30C53D2F

Previous signature

CBADA4E57869E6D434A784F1DBB7253C33191C73820C7C87BA340A7C77F6C1066BAC44005D2DA7E2B6B7358A249970BBEB421B605A469531E74135CAEED3160C

Origin signature

3044022009A318AE8248520402D1F04439C7BCD5ECF3910F2A6A2BF00CF1721EDFD8948402207D1E2A0E71A0D0FE2DB4CF9841CF678B2CDFFF91F586303EE92D3F03594DCB8D

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

005B2ADCE36F92BA8D3DCD7739B9F947FDB0047DFA89A3AC78FC38BB56C4460A94

Coordinator signature

4693CB1B6F525A6A4AFC482631F3317FED08EE538823F87E90E055BCE4EFAA4F6EDBFED03B1859DADC16935A9026EE0C298D976045844A80199DD792C465070D

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

46F7E460EDD8E92F8F88E05CA786EA87373D2D0FD616E8A4E7B77525FD5F557F0D8EC5C6162702282227DEC4AE30CCDB42C74AD131156A8430DBFFEEB1FF190E

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

E6FB49CB250990A6A81E72B4E751DD47BAD87761BE02FD2B7ED9653A10B96629576CE17A6664144E26E3EE5789E9E8875CCB958380D189FF5653A7A284EE3A05