Type
CONTRACT
Validation date
2023-12-09 05:08:37 UTC
Fee
0.20977076 UCO

Code (822 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: 0x0000A60EC381AB276FEAD46157F6E7564CBE430EBD7F24014F045B68AED539137ABA, amount: 5
  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: 0x0000A60EC381AB276FEAD46157F6E7564CBE430EBD7F24014F045B68AED539137ABA, amount: 5
  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: 4.985
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.015

    Contract.set_code next_code
  end

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

    17B4FD037F5B0301C04CED21072B0EDC9B6DA773B039D6B472E639E8D8D5B3CFB5CD01C949CBC2C8726E1993C7B9AA5CB4E34CCC81FD1132DF9A1811

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001FD67C743782D90189D51D34E40A85EAFB08B7F9744BF3BB2D1FD87BA0ED7EDB2

Previous signature

06C7183B01106C92664EEB34BBE3A0A3F4083848BE5188E13FFD302207D64E6B0E8A11187C563A34E07052CEF2A5391F824B0C2E5A8E69B310276FA1E0DACC03

Origin signature

304402207D92C9DE380AD026EFF413E948972DE420F508E5F3BEAF7410F87D32B80855990220400A1D834AD27E480FA80F7BC104EA93B18FDD5E8A1AA6425BCB2352620AB979

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00F20D42C7385432730B01D6B111EB3A9444728875E6730F93B616ABB010EAEAC2

Coordinator signature

E5B81E4B497A6539FD82047D8C203A9D4992D04A1A2E2E84E1FD4D5BDACBD4AA914801AB4371BE2A96B3E1018CB2411BD24D2DE2A6D7642FCCD57F2D2215C000

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

A3FD00736297B2CF9F3779E5A564E2BAE79A43F179102499C49D481B56A41FDC177FAEC39332689E7C403C004F4ACBB2ECBF6E15EB1BCDEFC04DFB67CC6CF903

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

7DA76F8704222E2D6A79CD8A5B876E01C4FDA47FD0FFFDD44C3B9E42CC38B7E39600D5F15D172B6C3C6989D34B2CC1CA175271657C0AE26AA35A5DA307841200