Type
CONTRACT
Validation date
2023-12-08 12:50:29 UTC
Fee
0.19784009 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: 0x0000FC5DC578B178F5C4F099B5886BED6EF94D4707245D25AB30CA63514FA4CCBB4C, amount: 100
  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: 0x0000FC5DC578B178F5C4F099B5886BED6EF94D4707245D25AB30CA63514FA4CCBB4C, amount: 100
  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: 99.7
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.3

    Contract.set_code next_code
  end

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

    736F1EBCD24E98786F06025749ACE1497F259ED29151598FAE0E37CBE1ED85DDBA9423C87DED3259C4E44A64F5C7654910F6D859FD18241D065940B4

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001066A47F92072AC9588AF7F324940A2BB12613E8628A2F3F4FD49B3CB8178B946

Previous signature

BDA6729A7547D1EA8EC74D442DA246647EC323DBEC9F03C249D2483741AFFF1ABD7F2912A7F72C47780FC2EAFF7ABD58F2CCB8CC3710E6918C62667D8BD3630D

Origin signature

3045022100C86E3C58580C5FBA89E44C9D252C343C1C5DE626344E8F67CBE29BCB18E3F0CE02207453EF234D91671DC81695AA9CAE6747066062B744181E25FCF835C4AB8F4E62

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0088AB7CB257F148C76819089ADD4C4749244C777D0176247BE068C8B3C87AD036

Coordinator signature

EC58032B00F1D74D2357C5DE54B920D261C4ABEB4E1BC2D77DD41617107FD72B4A2522B0D60E1D363909A981D1D6A21A8A0DDDC28890009CF5DBF3D52018DC01

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

DAC61379691CD8036AE9478B5E094F72FEEA85590A3F7CFE42E30C633CF061C6AC474B7162485F931FF608F4E547171D8427E0916548E92374314F504662270D

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

08C5E2359A728D29D0D635998D3C4430A336A57DED55AF8C1F2E4A8EEA483642DDC1C66D51595E9251DB42B08658C4085AD81F42AE55304F662E13CD03AD0807