Type
CONTRACT
Validation date
2023-12-08 23:30:36 UTC
Fee
0.21249794 UCO

Code (821 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: 0x00001DCF526FF46682AFCA9984CA510CE777EAE927C82DCAD6986E77FB867AEFA48A, amount: 54
  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: 0x00001DCF526FF46682AFCA9984CA510CE777EAE927C82DCAD6986E77FB867AEFA48A, amount: 54
  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: 53.838
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.162

    Contract.set_code next_code
  end

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

    605A68589F6D14D5C45384B0EE853DBF5D2DA68E0B762846F374B20EC283425A8C87D46367C03A58586BB16F9E4F6AC09C691485D0D52A744CE81A18

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00014276BF9661E4E08E80E639C40B63C3EB482A777E3C883C72322A15914CE0F496

Previous signature

C71EB5CAE38499F573AD7DBCA0F54DE8E7AB39D3B23D4A847FC86B23858C278D543C40FF563784243C168CBA3F81DC82C01208372A2078FBA73E623350AB2A0E

Origin signature

3044022001F2DF42570C38AC321B4BA56F69B3AEFD2454B997073BBAE9460558B02504DB022038F4D0E3B96BD6CF205CC9C6C36F62286B48B78BFDF904CA85E6575DB4A6E8AD

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00079F47EE4FD2C9624D2E31DB4FD9AFBCA00AB6C89B09F2AB94B06747D0305908

Coordinator signature

9D64C5A9F0EC2365C810BC72362BCD3C5AFB41A28CB2F12E2D7A8EB40327C521C83B14E236DA48279596B7656ADB281745D62B0E88ACCFF2161307672FE83300

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

878FB16B0B9A90BEABF90724C661929231CCE89869C2D527D25318F356F354C4638B33D19A743AD8C9592B9488251929F7A3B246CE24BA229F80C7DD0B94260F

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

B2707AC2116D674C027E43B6110E952CC2066DD0397742C53E5C7131E20A14444C7CFEC04A75A1B25510A54565BF2D69B204EBB21EEEA943ED73AA7358A6F309