Type
CONTRACT
Validation date
2023-11-30 16:44:25 UTC
Fee
0.20935568 UCO

Code (817 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: 0x00001C643B8C7899EFFC3FB622856FC3D625FA9CF24C053DD82A19724D2CA00C1688, 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: 0x00001C643B8C7899EFFC3FB622856FC3D625FA9CF24C053DD82A19724D2CA00C1688, 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

    0B1DAEA2E42DD778889187F4F62EC23D342C6F90E0B74699681CF0BC838F06DF7A4C49DDE77BC57205F0A936D97E0C95EDCC461AFF8F45CCF5EE40A9

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000160AD0872066D41AC457D09E12A59F5F58D58D55154AE90AF2CC9FB5994C20CE5

Previous signature

BE7F260B2F2C0603B5E3FEF4711E516518096C651448347C02CEB6A01ACE98D27E17C607F890D536803DBEBCDB614AC649AF4BA91470E33BA96892183D58DB07

Origin signature

3045022100BF515535688C40BBFB6EB3F81AE5D8176C8DC52043D4496AE752670E11EDCE1802202566D48327E59E8CB50401A34CFE13943249C327AE33FA121BE8EE38F5AD8FE2

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00996356F542D7815CDE265DB20E909D96D3D4785D5F0E812B1EDF16E424FDB803

Coordinator signature

F6364C8DE2220E0C7F454281AEFDD80A0CA6023E926D0786B2F365774B4DD4ACCE0A101EFBD17ACF2A5867EF53074605141A61E43A85CFF1A646BB1323CF1B00

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

64003E2EAAAEBFD5FEAAAAB4FBA07BA13BD138947A88F3F07E88C08BFF8F2C2423D34EE8491B7F2CC1B46EB9BD9424E82ED11FA1EC31F106F440412253874407

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

5BB7F09C4F8C9153A28F7227C9E18A199DF5967A511738685725D642D4BDA8B77522B9DF199B6A77CEC3BC4CB05E97BCD26F2399C746E09FDFA77CE91EB02D07