Type
CONTRACT
Validation date
2023-10-26 17:14:55 UTC
Fee
0.28740131 UCO

Code (821 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: 0x00008DD40CD42287A3C8282065F5BCA7259AC7014CD73109B570E946A977687C7BD0, amount: 0.01
  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: 0x00008DD40CD42287A3C8282065F5BCA7259AC7014CD73109B570E946A977687C7BD0, amount: 0.01
  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.00997
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 3.0e-5

    Contract.set_code next_code
  end

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

    1BA8F4C54ED8C8CC99A9D105104584666E7C0EB442C1636E8FFD8F01AE2583129E4C2552F5E83FED560B24DA40748B2EE830745B539DFF7E18A0341E

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001587D86E7EE6888F1334F0106CD73322BD56E0853819F9F3207B5107F755CFAA5

Previous signature

945D68D8E0BD5C11187C1E86262DDF06C04B89CF01DBC374E6F5B9EBB36EFC39012A762283F9142DC239D6F4C088CCF8D1E5C64F8FE1A78331A1D69E304C2A0D

Origin signature

3045022100AFF8A1E101E303C0C7824355E73C0711332B82802E95AAAE3D6D2748A149B6EB02203CF20E88442E345D681F7742FF8E649C0A81807D83E8C835A9A8B5ADBFFC06C6

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00E3C4B38B229E50B98A49B077E704304BA078748DBCCAAEA8A23FD7FFB1BE597B

Coordinator signature

BBC06B1211E64A0D693716BE5E674A733EC90B6A8F02A8AEC950C7E391B09EAAF43204B9DEF3E94612F689AB5E108F272B463376E76DDB75D137428B35434708

Validator #1 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #1 signature

EEB4E6CFC7DB5CCAF386BEAADEB92A17090DE60D56D9F557166FC836283F556E0C8F9F9B0CF3E84FE88CDF4A0FF9185EB8882F2DC76EE8F91A5A5B30EF27A10B

Validator #2 public key

00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC

Validator #2 signature

710A3B8BFB80EBCC9BF4316F2158FCEC85E2E670528FF4792C4E2858B1610282B990774D8A3E299C5E55CCECBBF3CD5F160BDD896D29123526F8A95D8DFCA804