Type
CONTRACT
Validation date
2023-12-01 07:14:31 UTC
Fee
0.20325024 UCO

Code (820 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: 0x0000F25C3DF408399FD5CC26D5A53C4081F6D6600B04B5EF4E41836D384F8B84C772, amount: 4
  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: 0x0000F25C3DF408399FD5CC26D5A53C4081F6D6600B04B5EF4E41836D384F8B84C772, amount: 4
  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: 3.988
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.012

    Contract.set_code next_code
  end

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

    C7E0D434EB4C9E81C326F2FD61D00353758115D91AF5726E10268F1FB77781ECA9EB1440B1762A8B670D508DD4216C3A4D75248A2583DD2093B36BDC

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00017EBFAE6F2C3AA4807EB448F788310BC2A0EFE318DBBCAD350A32216634F312F7

Previous signature

4C5FEB5F9E84C55EDD17372E4EDD9A9CE6A340000653E5E7BEDDAFFD28DDBA89078BD59ABC6B8C71519B7BACB7C8B568613637C101A44B60836FAA227B8E9905

Origin signature

30450221008B3F1DA8514221D1BA4F0331EB9478BD6AF463C37AC9372CA4AE2B851DB2B88102202B027DC1840D17725DB9C0AA62554887BF1EDF8AE22FAB3051C38EFEE5F6F35C

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0015FF238B60A50F48C9218F1D0E0C071727DD3D54514C6666BC6688BA50BBE8F2

Coordinator signature

CFD3411B0CA2ED6C77CE53556C06C16D60808D48BCAD52ED06DB1DA04940B6915335CD7588B57EE37E5C792E10FDD726C8CB7043D8992BCD6474CFC23955880B

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

E888421CC9D7D40F11BBF2BA65762BF71C360833DF2B6C6C12E332EA748FC3B4F1EC5708152AE884AC77BCE6B659B42B5D8D4EDF840652D55933B812C5670400

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

77BB63A5790231B44ACD7B8554C53F32BFEE18BFDCD3E53F926DD6EA6F5CE0423ADA0D3987E0EBE8B3B3487F7918346624B0EFC417DAD5EAEB94F3696DC63E0C