Type
CONTRACT
Validation date
2023-12-08 13:48:24 UTC
Fee
0.19825561 UCO

Code (817 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: 0x0000F95EA99BB551F530C7C2D6F18E67432A89FFEF32A30EFFF1CF936226411FB8A9, 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: 0x0000F95EA99BB551F530C7C2D6F18E67432A89FFEF32A30EFFF1CF936226411FB8A9, 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

    DFBC7158121487B3BF69AC0F15AFB907D74B1248CC932B0ABF8565FC04BE4BB874AC80E79D658178AEDA0D0E701A4B493BA301D89F42E4D26641522D

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001AC67F244B7DD4137CC4AC7CF50B3D0E0AC5FB90ECD0D7FDC2780655E23D21633

Previous signature

9E769C3B28D5B485E83A57A9D46D3C4C599F091B166D52B46FE87B1EBB960EE51A1D1C572E54341DDBDD71637EB53AC7605194FAB1AD4EC36B37BA531E54DE03

Origin signature

3045022100C91D4D77DDADC0A311D55819A0A1D2515EB415CC8FDFB9CEC97CB8E41F974F7D0220635BAFE3AA8C5801C573B2A97F2FF1BFADB2D1D0B47FDFF160A152E6796E910D

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0009737D9B8162F0CE5B11CBC8E630D4B5C4DADD4624A8CA5584B22F9A74B6F152

Coordinator signature

3955EEAE1839895D95B937FA51DB3099071772019D3B00C714C4EA4383F1463EAB8EEBC9EACFB7038CEB34EFB9DCA94D29248B3D65C81A69803032AE9DBB740A

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

0FBA618D125AB5F7EC0C2E2ACAC43B827CC23C6CD05209775C6832486DA7A6EF2A44B5E05683EC267BFCAEB4775A0B30DEFBB60064A44779035807E2E332EB0B

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

7B79E6C29ADB349CCC31E2222DDD52BFF179CC597A04CA49EC09B4B88996943A76ED72E5F78273FFF1C800C2DEFDBCA7F4EA7C416719F799E3DDAAB467A33F06