Type
CONTRACT
Validation date
2023-10-30 15:20:52 UTC
Fee
0.27183561 UCO

Code (817 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: 0x00001C6353CF7015A1BEB7096B1ADE63CB30508CBDF143A84818B53029BA13910199, amount: 1
  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: 0x00001C6353CF7015A1BEB7096B1ADE63CB30508CBDF143A84818B53029BA13910199, amount: 1
  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: 0.997
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.003

    Contract.set_code next_code
  end

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

    632F61F4B67E1362A56312F9F267179EB8A658364C5C7A4FAE52653F44E8CEADE3FBA5A7728446CE522A7032A9F57CC22FD8450CA0680CE820391463

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001A59C0AFB0D6D9C95470DF0328C8E0D54A0CE2E3D97CF87B53E1914881745EE3D

Previous signature

2D476F4C61AD88263879A7FA357D2FA75EF749BC7BCCFBA1EDE7633F229E481F93316F8805555AF7FBDEB3D07B7095F3A5057B640EB0288BD61FF51AA7F3550D

Origin signature

3044022068F7673A7B30C8542AB9EBFB61D7725F4E4EBB20EA8409D3B25C5A0B2CE24F2802201FCD8C1CA8298E885EDEAC0E27854F63E1C4FFD2DC7ED472EFA4F46997552D12

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0005770687249601C7559B2FAD5FBD37B4E056D80257600A51615E0894145EF4DA

Coordinator signature

1209E83CFFD7C935B32B33CFC6FABF554D41318D54861CA4665AE4499A242A63A7C9C5350EE425B89B2949E7C4314CFDDFBEB74A03415FDA2DD673B253893E01

Validator #1 public key

00011ED0B570D680BE5ECD58D2D121689DA73C46DCB38A01C6E10D06286040ADE30A

Validator #1 signature

09FF922242634346393EEBCAC5E2AE1F5A4ACE60D3538B5358612197FC5C3C2E63F539EA03E60AD219559FC496FD52AE6FBAC5A8D041CB5BFF8EDFB6609B1E09

Validator #2 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #2 signature

122428E6B165996A7791E9902D766959D9F71EBCD904B32BD97B14BC1CFFF61B874DAF3BA216DF9D72A58B7DD03242003EF6BF06EBAA388745A88FB709BCB403