Type
CONTRACT
Validation date
2023-11-14 23:49:10 UTC
Fee
0.17934485 UCO

Code (819 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: 0x00006AFF130BEB6BE9B02B80FFC13DB5EABFB0A7D167BAFC9F2DF8F141D7755FB39F, amount: 20
  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: 0x00006AFF130BEB6BE9B02B80FFC13DB5EABFB0A7D167BAFC9F2DF8F141D7755FB39F, amount: 20
  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: 19.94
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.06

    Contract.set_code next_code
  end

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

    EF7C931E11D8166F5F9990C9622DA7EA5B5832B68C2B1A3E60CE1C1EFA25F8DBEB0A8120E2C8282B2DB6C855161D5F7622F73C9DB1C6C34066A3EC50

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00017935F44AE5446D5B1C97E440D78230B7083B24A6722378E778DBE6ED466E0BCF

Previous signature

8E9F7147B4A4986BA64B9304AD706A636416BDA3AE8B6C2B543052F1757B901E872307787219CF40931C2D2B75720334F4A7E11B2AA84F51C8E002A34370230F

Origin signature

3045022100C505E5EE66546FAD1A37C3B3B979F63F7A97C4A272EBA663AD1E303E9CD3C47F02203964C38D6CA5670C3F29D2C37E41D865B20B13EEC985B7F610A7F39931F0F562

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00AD5DA5D7EDC37343DAC3731706AA55AFEF9D3192ECCD56D6A2D367156F3615AC

Coordinator signature

DD53C5A8E4A682D69739180C51B68879FD8D57CBAC7FD16B11DA79B19BC1987236720D55100A004B1C13258A87569BCE965E94DEB1B5F20B526C15BA0DFEB80D

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

3035DAFA07600F033228DF8922F78AB6BF419EDBE1F80DDC47BBA397013287DDD676F20E5EE4368FCAA708100778FC56415A4B8EE9CBB8E4BF2EFE5428180208

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

8C410834D2D1FA6F84197E46317C9A1D72C9ECE502D78F7979A1FE5991DE2F439B7A7EC66F666F565B3135DCB786701ED0E8D3ED8639AFAAEDB65183DE803104