Type
CONTRACT
Validation date
2023-12-28 21:41:33 UTC
Fee
0.20301061 UCO

Code (818 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: 0x0000AAE847768F278B0D458240DC4E5205C2CB307B81D81865338F2C6B831F6006B1, amount: 7
  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: 0x0000AAE847768F278B0D458240DC4E5205C2CB307B81D81865338F2C6B831F6006B1, amount: 7
  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: 6.979
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.021

    Contract.set_code next_code
  end

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

    CACB7EC8D7D1275EFC26B81F272BF9593BABA5B3318D1B454CE40D2337479C3CE84A77CE8E590256EE01988A945F178BF1F78571467DC04A8B1BF49D

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00011EAF16D170AC13DA4E3DEAB24559B5D115BB310F2508B5F50112B27148179E5E

Previous signature

9D7AB9E2030CBC27D724BA8A01D496FA565219A310CA615098A9B15473C38521DAE926801614F27D9F46B5014F09D92ACBACF877465177814A7197CD6CC7170A

Origin signature

30440220121D1691CC3F72E756AC517258591B5E03F74D0ED1BAE7165F7D55795CE42CF8022044EFC7915A4B3883D527AED5E0E9B788CFC28E930F6FAC8740CED4A3A842772A

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00D9601833664C525DEC73BAA5DE73265D97765F57679FEA77C346C8449B601549

Coordinator signature

8B32D4B87D790C998E2B125641DBC04A0C5D96D26096A3AD80B9DEBEB30C64A9AFF626354203EEBFA8C41CAAAE612151C5AC9F842FCCA65C7625C3920879E10D

Validator #1 public key

000134772A943DC0F7038B1BABA39E18841C12DD6682B1B6D1D15E08D7CAF5339AB0

Validator #1 signature

5FB7D59247FD239FB0BF11D701667D712D7B786C094B56D49538B842CA88A6A621CA716C0FAAC9616333BCFF4FED8DFA80557E25392EF4A35AC48BA0E9932F04

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

0416B35E60CAE2F7A7BF58950BD2CFF4D83A49E830B82D160BE255E7FB046437F981B79C08F7DA335C7D0F2484F62B79BC3A241FDC79BA9B3AF07DE0C2A2C004