Type
CONTRACT
Validation date
2023-12-06 17:15:57 UTC
Fee
0.20555531 UCO

Code (819 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: 0x000067D8760BE3E8046DB944187E3B2CE7C96AAE5EBEEC159710723DC2507A7A7926, amount: 8
  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: 0x000067D8760BE3E8046DB944187E3B2CE7C96AAE5EBEEC159710723DC2507A7A7926, amount: 8
  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: 7.976
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.024

    Contract.set_code next_code
  end

  export fun get_htlc_data() do
    [
      amount: 7.976,
      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

    C07F72D672B59EDC4B6E6BA8CB6DF9D8DE006A335EC1A546D586E3207FCDDFBD2F46D67B122F217B8D571ECF6AA520322753D02A64587BE7A79415D2

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000180B2A7FF52116043C1032B6DF88826C6DAFAFE8618202C5CF1D5DE95D657E730

Previous signature

B1751502EFB38D42659E03992A9CA4339419AE2C18D4B9C849F48EDDA638A425606ADA8C6C0B1CCDFA002FF07A86AFAF6F88B6C0FB92D656E8D8C82D81DE6405

Origin signature

3045022100A5E9D558F095AA1120BF8B7D5292F19F53EAFDDA13F51111CAFAC8C547C21E8F02200F5B310E13C2DA188CEDB76D85C3C86B608049032079916BC006845E10256BAB

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

007ADBB6CBC427A0857FBC4B810CF9328654A5E16EFEEEC772EECDD35AB44BFCF4

Coordinator signature

12AD251AD3CA6A6A866DB7C17FA00C04278279EE2FAECD60896C7D56CC6B18CA42C120976344B8FC89A644F0C9AD4EEBA27CAB39AAA1F19673083EDF12333E06

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

EB614C0E992F629E4F5BC38E3370F3A3360FCC1DDD236C50A0A0E2F0F2C772FBDA9DFE0A88127A5755A10A9B290D990876E7C7F0FB3326BB559CE487D749680E

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

703B4C1CE33C39BF6564EFC91CD62004EE0FAD7355E8BD33E059BAB07990556A1D3A4E08FF2F2B5D0A1C9C7FBB608BA96EC4BBFD8AC5F1DD85856821FDE23F0D