Type
CONTRACT
Validation date
2023-11-21 15:27:00 UTC
Fee
0.19015142 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: 0x0000F0399652294DADBD09B8099A7FE9762B98E7DFEC079AB2F1F5D33D8C933FEFDD, amount: 0.01
  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: 0x0000F0399652294DADBD09B8099A7FE9762B98E7DFEC079AB2F1F5D33D8C933FEFDD, amount: 0.01
  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.00997
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 3.0e-5

    Contract.set_code next_code
  end

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

    B588B209480D61C9F28E7B11D80CF0220475601833BC34B50FDC54AA0171628790FA97452CDF26C62C8D95D151E0CDF04E4951F6CF8B1115B6D2847B

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000161B7426D746E5EA64A88BD43899825DDE237237D1469B5BD2C61AB8AEE22D80A

Previous signature

7B1B4444F55310052EA1B34706D23EBB7DCD4B07892C8248591F92A8404E4CB188D4C1E63328884560D75A005CB5774F2F51C9F964DC332F1E38B3617863050A

Origin signature

3044022066FD07F170BF25332B4E257E7DB5526A65CEC652228ACAFE44AF185899F0DDFD022043D09D7E532256AFD82CE1AD0D6B7F16F622C34FB8CECB504FE0A696CEAF3685

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00DB5D5A5B32E47016C55529DE68AA0D40226C1AB00AC8DF091E73940ECA27E0B8

Coordinator signature

154BE09D1F82E849E1322D841CBE65B95FB325B52B453EC02AA181A500BFBF255B4E3CDE8B0F14AA8F33A5F2EF2FE39A8176B879F9268CE7583772F52E012A07

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

5B77ADE4D9917A1EF648E56A44EC00D53D158324AE91A2D49D2A19E75553C388CB089A4D08514494214956A232C477FE1440D181E627B303BE8F7C5FD0AD5C0F

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

3F705F2D7F3DD615DEB46EBC5AF8921D27D6CD2E7D9CB19D2688C1FC634B297B79402FA4019D4B953CD6133C53A7B27C13EC2ADDBE8236878A3A9B2C0BC4ED01