Type
CONTRACT
Validation date
2023-12-01 17:22:12 UTC
Fee
0.21197207 UCO

Code (793 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: 0x0000F25C3DF408399FD5CC26D5A53C4081F6D6600B04B5EF4E41836D384F8B84C772, amount: 1.0e-8
  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: 0x0000F25C3DF408399FD5CC26D5A53C4081F6D6600B04B5EF4E41836D384F8B84C772, amount: 1.0e-8
  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: 1.0e-8
    # Transfer fee is less than the minimum decimals

    Contract.set_code next_code
  end

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

    8C3EA323730820BAD3C5751C78DFE62E589265B0E36C9B40F970AF880F344060D55FE2D6AF9C60693A23D66013E791194BF82D83952CD572C8E9C910

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000168C89DBD03DF7936235A8391E8B5864EDFE9E297F579F483096B41893B499FD3

Previous signature

154F0C1E1CAD0A5FDA5FC24C004117BFEF00E9575B803D5AA1F83A55F94B902B24398A41549D8F6EDADA29724EDA2FE2E1BC934CA56232CF0474E8557934C905

Origin signature

3045022100852074F9B8C4D2C01FBCC91064FAB3CFDED78AF7122B4DB47B19F03761F584F802202394C75EFBDC86A6AFA09FE5D2E43C9A0AF1BD0CEA64761B1664EC6FB88D6A34

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00E68E9F9CA1E281A02627F428C32DCD803FB9CB609D753F2C727D50AFB84877F4

Coordinator signature

532FC6C30D0D978059F2B08E771AECDBFC80E3D64D7455523730029777020F977D3F71483CB2AF64164C05B58088751321031424051CE07F6AD1FCC4A72FD90C

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

31E8B8BE2559FA095BC01A4A010B7E0055F5E2C4404B628FD91EF137E2633345ECCE1B9D407C8B36448CC30016495157CD889385D4D0DF83E253E7295519A90C

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

B72E46498AA180A248E508427CEF7D56D963A657AE57C9A83B863C17B546A703D5D95FAD5A3413CD6295E97F3543EAE1C3C9E10B4A00BF7DB4D6D04DEB055305