Type
CONTRACT
Validation date
2023-11-30 17:03:40 UTC
Fee
0.20918329 UCO

Code (819 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: 0x000044DAE02EB037F0275BA1732C59121260DA964D75869F95018DBB2DE39489FE91, amount: 10
  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: 0x000044DAE02EB037F0275BA1732C59121260DA964D75869F95018DBB2DE39489FE91, amount: 10
  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: 9.97
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.03

    Contract.set_code next_code
  end

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

    EB46A11C383FD4FB4471985C99A98B9ECFA6D69D3CBB4BEB2CD8DDC382625FC1251B2EA5A383191FE09BC5CC37A6B18356604A9E13DBAC08ED78E204

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001CF2AFA01417CE33422C7F0F32E9E492105303A4DB6EB31D6A9D10D024B2FEB25

Previous signature

0800D7876F8B4F1F12FD38A19BDA887366B98F58B5060D4A11730C0B296DD3FDC095A6B9EEC2BC9631549CA2855EAA66EEBC766B12C40403B90326CDA227150B

Origin signature

304502210086E17EA73E958CCCD167CBA0CACE48AB8457D856F27171397768259F51FD59BD02206C47447AEF38500FF3C8809E51CDF7F454A4E99CBBB93425B35A27E44074D2FB

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0057188EB7F16718AA20A6370369388B2FEDD59526DE992DA0E6106B47E422DC1A

Coordinator signature

B219F4201013A79EB0D5CAE4BE9488DD0A175044FDB80D3F4451520C33E05EC12A85926C18EEC44B68455836F3617F4B8E869854AD6F30C35080CF8340410D0F

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

92EB8858CB18AA90A444F5D37BDEF10D72E94ABAB2DA08947F6AEAADC9B5685207550A04F40C37D2B51E73A09B00A268629FA1BE77B9FC0B59548D0C920D2007

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

BAFB5B664432DE83E8B3DCF973CA1E32BFAEF3FA284270527339FB629641E9893F926662C3D065090C8415265CE258EA0C4164E46DD4A806D927C8CDBA0C5D06