Type
CONTRACT
Validation date
2023-11-15 22:28:17 UTC
Fee
0.17476289 UCO

Code (885 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) == 0x00008DD22E7496E86901E9B276A1BE6F9512EB09980CC04C7B76495EF37D5666A709
)
]

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_token_transfer to: 0x00008D5D4054C44E2D545884BD557D7E1CEA9B3669EB223C11CDADD6D99A1334F9F8, amount: 0.05, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
  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_token_transfer to: 0x00008D5D4054C44E2D545884BD557D7E1CEA9B3669EB223C11CDADD6D99A1334F9F8, amount: 0.05, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
  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) == 0x00008DD22E7496E86901E9B276A1BE6F9512EB09980CC04C7B76495EF37D5666A709
  ),
    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_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.04985, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
    Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 1.5e-4, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827

    Contract.set_code next_code
  end

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

    95A7154BEF99214C1F722EDBC8436F6DC81E72688C93A487339BCEA7A143E71279C4DD050A39653E86395261BADB3C6AF3D3A6E627E1C4C6179FCA3D

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00013F9E7DEAFF7DD65F16216ECCF98C083D15CA4B7CC5166CD8B4425CFCF3E2DCC1

Previous signature

0ED7C52C490334F0DA94ACEA0204CF6CEFFFF0F5885306CD85FCF5D82820BA878E76A642EFFBEB24ACF6798A4A4CC5B36A170C52073A05002B165D9ACA8AFA00

Origin signature

30440220681B2355CCF06A55FD34BFCDEC17A94090B7CE3E5360569C3AE2641273F2A72B022043580D8436D9F580324CBB0B53CC560051A93BBD3592A885E44855082CAD5A6E

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00A757F1E38615E52C48D5D60E7217484D7547B14B7E06DF4FBCE826A27A9C0805

Coordinator signature

2715FD74FF71C8631C8B16A7AB9E4DCE30C484D945610D0583BD0A5A925BB56BFEFA432406B4FFC7F355B79AF7A73DEF1EEBEF81C6D47F4C476785111B368703

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

6E58FAB2A5F85FC8209851D71A6C3B76850E85355FB8F6A8DAE8D4C742AF6216191DAFF18E85642A02CC1AD390E88B450DD12A28560EDF5BB020074B0B9EB501

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

BB0B2F848C8921E908F10D4C1820ACA2F2EAF7DF4732478DCDB0631D70ED26B3C3C446E2934438AECFFAFD68867439790934A4815B7E2D11CAE6676763DCE005