Type
CONTRACT
Validation date
2023-11-30 15:52:51 UTC
Fee
0.20961204 UCO

Code (816 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: 0x0000D0908B3342519EE710DEA10FBD3394E66A558797EEDFB410F82593E0EA92201E, 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: 0x0000D0908B3342519EE710DEA10FBD3394E66A558797EEDFB410F82593E0EA92201E, 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

    9DC37C992437DB01CC58625889C4452D04A357C9BE19DB5902C3B4D18ABD8B78F2FDA2DB8D3A13FD179F0D9F4ADDACBBCDB363A56A67E2907B42DC3F

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001096DCBC25CECD2DF9BF75427416BEE19AA506951F52BA1936FFF417FF7F38055

Previous signature

7F20BAD20F185763C261229ED31FE953B47E98A283840F859D7DF7BB7B1E6155AFBFF4F0DF966D9272978FBF4A2D02BAB104C209E548E13C1D746D45083E5F03

Origin signature

3045022100DDFA367B89C620035316094B2216811F005F8FC4DF3AAA9E6349A1927C8A783C02204C146A7B3840F819BBFDD0735DE6AC874385F2EB666FE8DF8D0E0CD276963F43

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0069B9CEF7DB4C30692805E5D967EA3B71E6EEF45C9672905A84D3F6B562E19432

Coordinator signature

ABB3B06F45A28E6CF0F8F53F22F4F2B6F0F9E4A3C580471B584C086D43A203F79012CCB956C608C26CE18C08AC348B9E744BE623E5B11B917564E33B783A4201

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

6A76A490C7E6D7272929147C07FAF8935F979F4EAA1FE30988F2D8E2265FABB2A1FFD5EFF8140724D09A642BD6EF1CEDD335ED33ACF10EEB4D23AFBEF31C1901

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

DF172BB84036D3145A7315353373782DE9DF04D31463D6F1E66B5E5A884B44EC4089BE588BF4D29F511AA60CFCCB8F2BD42E01340236CEE4EFFFA68066A86B05