Type
CONTRACT
Validation date
2023-12-02 15:11:50 UTC
Fee
0.21276276 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: 0x0000FBBB22C44885F42E897B4CE0D3DD921C4ECAC303EEEE9EDD806DACEA55B70D25, amount: 250
  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: 0x0000FBBB22C44885F42E897B4CE0D3DD921C4ECAC303EEEE9EDD806DACEA55B70D25, amount: 250
  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: 249.25
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.75

    Contract.set_code next_code
  end

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

    70E5FE9B20FE2A58DF73D3BF5A28AB585C1F3BBC0BE23B01346DE377A683A689EFD7BA0CE70FE1A49782F533ED6683941B6CFE93966FF58E81EF9F47

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000149E46044CAB74B607FEAB2B94BB10D168BCCD42F2CFAFD686DFE48E427C34232

Previous signature

5A60EB3C75FE5748881B196168DDC8AFF95FEC3392D27A7B88102103227AA816F50305F60BF7702E82E71FEEFCEAFA12E41434142993617A9DAE4BCF2A3DC801

Origin signature

3045022100CDBE612428A9157D6C4D350E0422247BD62A3A78544562D51B7B60EB9FBD723E0220296EA98BEF5E33C9751DEED5948B2113F166C1B18C822D92333E9446A00AB7F9

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

008DE7BA7A1550657F373BB311EAECFBC1320EA05455EF99F407E8D061EDC356B7

Coordinator signature

D1645FB788BFF1A37C82F95802E4FBE3249994B8150216E70D2B08C3AE232ED29AF9D0C89F2EBD02B9D2C10D88BE93CCF46DC1ACC8B9C0551233808764BDFA01

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

A5E2B70EA381889C4B71D62F50786EC15DDF57CC846355B2CF594DAE55AAE96E30FE35C4F58E96E624C5BB3B770A3542C7E7F9B70F4985FDF0599F77BA3DAB0D

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

243DB3D6DF70A22A42178EC7FD3F65D56DE1E28D80F2CDF15D0E139DB48D0EDF42C7EE0AED6D2DFE18304A1DD2FADDC0018C6894F95C2BBD12053661A013200A