Type
CONTRACT
Validation date
2023-12-28 21:28:10 UTC
Fee
0.2031703 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: 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: 0x0000AAE847768F278B0D458240DC4E5205C2CB307B81D81865338F2C6B831F6006B1, 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

    24EF37E5649D6F5FFB92BE2B2002D6B713B6BB71CC114026E974A92B04B080D451FE59686181F3C5CB4F9B55B198E496F3C7BC8B4450311CD1E79AED

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00010E9A5414CB33FFF6CD1EE5EA33FB4DA8C826125C497A653E79AFA22FB9159A2C

Previous signature

FA426E3A1BE4416697C5190DFC86E519760F6BEEE436D414D130974B8475D033638DB3929FC4C6579AA7E1D779682BDD0567C0E08757988BDF03A1BDB6F34903

Origin signature

3045022100E6748EC0ED91850B3CBC8BAA0D91DE86241BBC320F6C8B82F8FB22A80FB4B0AD0220753F225D9A3CBD0D6AC91EB8354F68FF2910DE70E11D5F1C9DD8BAC5AC5AC7D8

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00715F03B09CAE03DCE12B7C02C26AE17087439B20A71CBD9582A26671CA2461EB

Coordinator signature

E8D7EA8C803871D0969AF69641FEB16DC8B6A9273318069638BC0EF1CD4C73B67C8EE08A84B3997267C396FD81EB5DF67932AB4FC8F659AC67D2D20C3829330E

Validator #1 public key

000134772A943DC0F7038B1BABA39E18841C12DD6682B1B6D1D15E08D7CAF5339AB0

Validator #1 signature

3E4BDD2C8040238FB1D75297D01A9B051389DBEC281D24B8AC4F280189919C6562D4DF5C572F17BDD46FD17946C3170889FB19130F77A467E858EA5FC382150C

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

16CC3F91ACAEBF351BA30D97B6AC35D153C061103C76D5B33BDDBD8E11CB3441CBB7D429E47AB990E9D5225DE6033A92BF35268FE8DEC36E56C9C18CD625F407