Type
CONTRACT
Validation date
2023-12-11 06:43:27 UTC
Fee
0.2245427 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: 0x0000D497E56F0F796C44C50067D58F6F0199F98994D2CB0988EB5B66CDD784C0D7DF, amount: 5
  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: 0x0000D497E56F0F796C44C50067D58F6F0199F98994D2CB0988EB5B66CDD784C0D7DF, amount: 5
  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: 4.985
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.015

    Contract.set_code next_code
  end

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

    44C2CCED21DE174E92ED87EED6FB6A54D1CF77DB968E0F1D91623F593C77F100649622FA785F3978CCE6BEFFBCF76ADB5D716AA78EF6D2964D752091

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000132E7BF7CA6D4DB42E033EBD249F59E55DA844BDBFE9155B40A61BEAC06A29041

Previous signature

46F88B6770A1C51012BC368843492497A4856D96DAB080F1AE3BF1B93A4E8D438FDFD7328B97516EC18CBE67C8A012B55CCCA2765F7431AEF1FE399C461D2D07

Origin signature

3044022024A94A630DDB4E58D5AF4FDC73D3A26AC26F73BDAD8F88D3770ADAC59FB0CE6A022063F2D6BC2794E50DAABB263BA0110922A830F966257EB7F4F44C33585C558194

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

007B323A74889C200DCFA2D53699AD5B4162AAC104DA6AA18877BD6467F77D9C51

Coordinator signature

892234CF507A07546A591692BA0ECD96B66E1853D019584ECEB4C8EDF7E4740D92F5E892805C11ABC82535D08E02D192830E8DB63E56E303DC845B86C8CD4F09

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

7480BC119855A9C81A32DD44EBD48EA8D9B2E47AFA6AD6B125FE99965EA427B3F17617513D92B3402B6DF833390661C5923D3ADA95C3C59DE4C4ABD27FDAB60D

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

DA42266D73972BAA759369D193E3611C274D4047BD582B87BC85BAD1A2D0D7331DEFA7BD9EDAB715BE6FCA613CD3FF358E4138E21A8E3A089EBBB8842F7ED402