Type
CONTRACT
Validation date
2023-11-14 18:08:06 UTC
Fee
0.17417313 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: 0x0000F74EE60CE89C9227127F41A4DCD1946F11721BF74D07C812591D48611D3601F7, amount: 9
  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: 0x0000F74EE60CE89C9227127F41A4DCD1946F11721BF74D07C812591D48611D3601F7, amount: 9
  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: 8.973
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.027

    Contract.set_code next_code
  end

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

    4C6331BD8FABB927C713E6EFF6249419CF835BB97BFF3FAD170A575686099B7B998BB596B86EAADADF0AC58984A9D972D04E9794B535A809C78A14FB

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001DE8CB61F4FFDA312CDB2C6E3AB90B7D7F244A8788B286646A08EA193D040B4CE

Previous signature

6CAD121D8CF68A0C448EB2880B2159CA097243290BCE1B05E7974BE02D4D3E4C8CCC94BCF8C6F99450D139DA1D1F258CCA9CCA311D46DDED138055865D24B505

Origin signature

30440220763E56D5C6205A7A8A9D3DEBF943F881881ED9E4AD62C42D545DFB92A45107D00220471D954DC22DF1CD30729C49039CE0BD0524038EBB9CBB85A34E57AF75F39091

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0039C0F5B1D83BE65880FE55919BF1896519141449B8C8F86169149028CF258067

Coordinator signature

3C77A67442874A99BBC53E201B8C2BFBDC2CAB210AA38ECB1D0392F2C6981589EDB3DE191D62A10893E043DB1BF0EF59AFA2D8B2FE936D9F203D371D9AEB450D

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

98A7724D6EDDFDC04A4FCCBC7F082A6B4A89865CCC2C4EBCB21A412600132ADEE10286B028C7CF651AA29B4B0C1C2EA24478156D50EFB9EB2E8F7B6FC7FA7D01

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

3EB8636E6EDF1F301251E49ED7E3A4D541A971886125A0BCE93B6BB420C63631A7AA05C47277A8D5652A459BF49D6D6B0C83E487751BB0F0185BDA28C009000E