Type
CONTRACT
Validation date
2023-12-01 13:49:18 UTC
Fee
0.21332479 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: 0x00001A485B1A826BDA15AF83012F0CCE0E0DF35C674A704C965D7FE4E48776E9F098, amount: 50
  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: 0x00001A485B1A826BDA15AF83012F0CCE0E0DF35C674A704C965D7FE4E48776E9F098, amount: 50
  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: 49.85
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.15

    Contract.set_code next_code
  end

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

    2AE15B21D58B1C5A2B41590411CCE6EBF2FBECE21FE3F6FE114D878139935A7D10B8D9C6C29ADB8A0DEB03A9DFAFC79E59A28122B5D126A2D2155125

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00016FB14C11AD715C524CA50028F732CF41C643ECEEA793A6A279C9DE68C1FD0FCB

Previous signature

C0567B82661DB1426B9862719EBAD6FEAB280C9427B54E6ED69DDEA3CEFBBC6FC8AC8704166A34077D1A83C6B11B863EAFDD480FC764CE4BA298EC4E7554AD02

Origin signature

304402200CA41D81B1554F178495EC82B3091C59AFFB0793AFB66D3DDC9F56184CB6DDC0022027784250C6296A134A4360DEA4E4AA9FDF4D0210EA6C8760761AE558069E65C1

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00352268F7486C020D426E6F663D451653D1A4DA89325A5E6611A193737D6E52AB

Coordinator signature

F6A8E42B25C6BB4722B26C145BA63CD308B50A7FF46A4DD5D520AC456453108319743D6930EFDECD518B856DE771537D4545059FF7E44310032DCB7CA895BC00

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

52AE17C7C4899AEB906A08E3F9D802D338558FE36DC2C0E25D1762CE8A30053111D277D243ED6DE0FE57CF17A8DAC0FEDA7D116C8A481D24DBE27B5946D7A703

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

7265C1AFAD7B74475C75A1A76C94211531B7BCC9715DF5CE63987F3E34545F07269C2D879342675A23943B970A8E220AEBC86BE6EF95222016CEDFEB9E2E690E