Type
CONTRACT
Validation date
2023-12-29 16:18:09 UTC
Fee
0.19933725 UCO

Code (821 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: 0x0000AAE847768F278B0D458240DC4E5205C2CB307B81D81865338F2C6B831F6006B1, amount: 12
  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: 0x0000AAE847768F278B0D458240DC4E5205C2CB307B81D81865338F2C6B831F6006B1, amount: 12
  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: 11.964
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.036

    Contract.set_code next_code
  end

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

    854C81E11E6FD05065EADE78050335E2555E9C33B928E82718903F16EFDCE3FC350E6FF2AE28CC8C5B9D3DC709A1CD24992EB077AAAADBF96B2100C8

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000165C8006A3C3D2D5F916A8E359B356BA679F9354371F68381B9DF9301C0C4E922

Previous signature

0D7547E8F1FC054A9243866625506AD5F5B632CE7C215D94EF5FB85B741E8C9245B1F3AA5DC6FADA57F4E547283202425F91AEDF1B5ED59DF884330E3548B709

Origin signature

3045022100D5B1103BB2210453164F8932E028F1E7EACE826C258A2D5A8AF163A401F71E9A022074D27307A8E86884CF2C94AEE926E1C8294A14B5F8B2BC1BEC9AB1D4B0D28191

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00841334058B2CD889976B8B6D2CB5FBB668905EC117B3D3BF6D0AB346B45F9947

Coordinator signature

ADC6D4A8095937E531240C82DB8D5FDA8AC89591F581E779E7DC5A56D206F08140F4A53C826738B1F29D6E54E993D0B000F8BA35EA694BC036B59E93A95A2E05

Validator #1 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #1 signature

1AF33000316BFE269B2D75D15A28C1261A4678E9E03F23EE50AFA6BFB08414F7F92B94E463BDE3F0BDCBB436065E79B95D6BDB4287076308B7C67B5C21561A02

Validator #2 public key

000134772A943DC0F7038B1BABA39E18841C12DD6682B1B6D1D15E08D7CAF5339AB0

Validator #2 signature

401E8452D344A812BD710D366A346E1625AD1795977E5B6D2F43918BD9BBDAE9D237E86B518F84D8FD3924B4FDE779DFEDA661CE97834FFDB83D1C46CB47CB0B