Type
CONTRACT
Validation date
2023-11-26 11:12:56 UTC
Fee
0.20867878 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: 0x0000BF431D64A7F738BA91391C9400F404AED16DAC00E04F65677FAA511B4B0CADF0, amount: 200
  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: 0x0000BF431D64A7F738BA91391C9400F404AED16DAC00E04F65677FAA511B4B0CADF0, amount: 200
  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: 199.4
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.6

    Contract.set_code next_code
  end

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

    B9C5822FB134C070B5F1A1949E4F84DC01EE2EAEE2ADA49980924286A408CA0F8088E0E933DF60FFCD4AEAC170E56F74626D522E12080C74E69C7985

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000152A64EE17B2CFAAC88C3E58970408C751AD277A0E30589FE64EB4A05B27A00CD

Previous signature

C9AB6AD558E679A1BF8BB74351A420B4A0E0F7CA79D900057A41C8FF21068DF06497B2381A64BAC1489943C0E66F57E37632EB27C4F503DFB9CF0D1C5C7F650C

Origin signature

3044022013FFFACDEFD6FA54CD95443083804ADC890F1624B252D1318D14CF4BD72BB84C022047C4C7F5BE9ACEFDFFD9131FCB7DD8FF338E6463DDAA11C2BFCF0C78D50BA708

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

006C51580FFBBDCEF65903C6C8CABD36F7800BA9A1DF6548A8DABE4993EAFCBB57

Coordinator signature

4411A4E4F7EBDBC2C3FE5CD4782F8581DC654447A3472D061E1AAB3EAEBD6F93D9CC3142900B230F14D1348A862A589172318E453B9BD4A10AF61A8F6D8DA906

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

A7A761CA85075744F42C2A3ED4DDA367BA8A41330A92600678E20CCABD828C74CB36D654806237983A2FAB298C88AA6E6ED3A435294919C4E51A97183A34E20E

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

3767BB41C746E80C255A10F5EAFBA1550B039190A4DCE8E5C7FD6B098AEE10EC1A9587A8460B5A22E56F043C3AD9FA00FFFB954E018AB6B820C5104A0540C50C