Type
CONTRACT
Validation date
2023-11-14 18:13:56 UTC
Fee
0.17476586 UCO

Code (818 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: 0x0000F74EE60CE89C9227127F41A4DCD1946F11721BF74D07C812591D48611D3601F7, amount: 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: 0x0000F74EE60CE89C9227127F41A4DCD1946F11721BF74D07C812591D48611D3601F7, amount: 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: 7.976
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.024

    Contract.set_code next_code
  end

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

    E865BD7EB7495D3F95F78E0D40CE9E0C7AAC6DB61D1C0391264E16EAE29F1CF902D5D4AA8E18EA74CC665FD4649E5B078F39E466EFF1F0518DB2E45D

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001B46B73CFFFD11415A840AD52582D568C157CFCFF9DE7E2DF75CAD5A98DB211E9

Previous signature

F7B47C0540B7725D480C73A896D44CAFD7812A6FBC247154AF822AC996456FCB95C0E6E65618E65BD2A2AB0C3E88D61E92D32E4A1CCB703489491E878F39C10F

Origin signature

3045022100F899F9439F72065F6BC42A95DACF46E3F51C6597B97B15826CCF2F9C2B38014202202433B37012730F48E31F8B3BCB47DDCB022DCB066201157F900DDA08E6EA0ACD

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

000B6ACEECE80E1FD9ED17D2558E2599702298FF845737DF3DE2DA95C7B9B0B266

Coordinator signature

1553F725465D81FE482A6FFBEB7EBEB44242AE465A4B8F91257988738FAC6AF77A7A5BB60F40247B6342A301534BCC88BAF72133AD0BFF1A45166B7B3A517306

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

F8FAE68BB2086D2643A2591CCB8B6390E554B10FAD6E54C5ACE308CCC5F09EE64E985C3A612678A596EC283298AB5D170A80FD10527E758D333BF38B3D2A5106

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

26977C19109D782731D82EB0C4367AE86482F0F317C8C46B54C0415AE1DFACD677AABC923B37588F120A00716C77F54D5596694F2AC4EBE2EF3B418120C3F400