Type
CONTRACT
Validation date
2023-12-01 03:31:27 UTC
Fee
0.20345037 UCO

Code (820 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: 0x0000BD8A7CCAD82D84CD740DE6C86B205E93BE1B2AD730E1699904B8F4A3023C39D1, 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: 0x0000BD8A7CCAD82D84CD740DE6C86B205E93BE1B2AD730E1699904B8F4A3023C39D1, 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

    9813183EE204B1CB99D3DEB3E0050F2C44ADC24F3D090BBE4135A0C2B04491DE5A4EC54DE3853EE80A0C60A9D63B4F91A9B40B1490E2D3898DD2DD47

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001764498B68BDFDD780398A457396FCA128787AD1A3FBA77A51C3EFF905E77A671

Previous signature

D0A22660EF8B9B6FD284E08B6B9A0659179657EE7F3496875DABA0EB4071087E93CA50663954CB5D2BCE75144C77716398C4E9B7E6CBECC5F5E339A0FF983D02

Origin signature

3044022079C0807E5E0A476FD2A5A1B704EC0EE8A0E89D89D96C0A44E774A32A0321AC8D02207FB473B3D3F38A786C356BABB284B9280014D9B16E748EAE643FFB390D09512D

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00F07C0700EBF18B81C2E2218DA354B7940CD3E6697C045D33BE507C1C0D7508E4

Coordinator signature

DA7B248B665A8F56A567390ED3E4F5B19D5D64C7C45DB23B54E67E018645D227B4931FA879EE68F2927F4EA6B1F85D8B7AE0DE7A6E70A59A65C1FE9834066709

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

CCA57EF769F6A2D230CD258023D04989FF77B17DA94BC70CDB27D0182FD44276E55C0D8447BE36671BEC16501A7A112B5D25B7E82AEDE7D8D4609BFD4AD3D305

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

74C3F395BDC95B0D5E68175AD02468D2DF17578761DB7437D75496869D95BB5032073203EF8396072CDF844DA7B31DAA9ED3871189B8789152EB70E45F35B104