Type
CONTRACT
Validation date
2023-12-28 22:13:30 UTC
Fee
0.20273175 UCO

Code (818 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: 7
  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: 7
  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: 6.979
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.021

    Contract.set_code next_code
  end

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

    9279A89CA0F1D25A170FEA659D51C976D0E9BF1F7984B4E283830EEC8963E8533A9C863DD640307B9AE1E815EEC7400B22D13153BCFCE2E8C0447062

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000108A089B31B708EA2413B77F8C5E426358CE35220A9D7309827754EF4618DAA4D

Previous signature

DE3112EE91DD5276894501FBD425D7D9935422D5FCAB78F6773EC2AA7A0D9BD1985C20C9B1DB222DE59B1E8C2F4ECD899C96B98698083DF9DA82B16AC11E490B

Origin signature

3045022100DC087F9FA92F9EBBAD8B0034F3713C94D3D033709FBDD1589C198972A45E857502202AD093983672DF3505F40689F8E3B2B6323D925A35D902A3FEDA70EA58569B41

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

008F901A5503F0EACCF1FF1D7556EE0DC0C91DD87A31554EA9238D68430E003E63

Coordinator signature

3880EA772E7EFFF8EE5B068BB1954F0319197DE8B84827DA71B9C05EB00E4E8FDDDB0E5035A494E0E7B548B473BA372D9BDDEBA3A1808DA51871F30EE65B9E06

Validator #1 public key

00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC

Validator #1 signature

8B7F69F61A30D0866EB9B8F293C9E93A357628A71F7E8C1A6AAB97E4532C45B70C1674909E4B910EE1E5B41FA3BBDDE5B44F9E04893870100480BBE017A87102

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

B946A3FF88EBF3D5796FE9B5DB747B7EDCF9E28C9C46CB334A03E319CC8BF8AFD3FE94329D6DB5C434F2F37FDF2A84EDF222D028AD101A4710F45889D608170C