Type
CONTRACT
Validation date
2023-12-01 10:33:28 UTC
Fee
0.2110995 UCO

Code (818 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: 0x0000F74EE60CE89C9227127F41A4DCD1946F11721BF74D07C812591D48611D3601F7, 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: 0x0000F74EE60CE89C9227127F41A4DCD1946F11721BF74D07C812591D48611D3601F7, 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

    FC6D2A0AED9F54C0E41225114AA77107E80FF6441B0C4CF43967E06304AF591540292CA0F1F05D5B98011394299E29AF0FEF5DC53212CF740B3419F5

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001650ADBA5215217AC578004818A767AB1127956D759EC63DCA9EF7786BA3B1B19

Previous signature

EB46956AC716AAF741B3B4C0E883C563A67EE9F65FE4523EFD6E75A8824BB3E23AC2559F441DB4B14706573A6962717BE25E9424C6CF99CB066F63BE440FA90B

Origin signature

30440220458F46D4EE13CAFC2539176C10C6DC1F0477469FF51CFA31E08AC9710EDEE7A102201BFDF9CBFD1E469EC1A4F9C00ADD596049453DA4A92827926A7034EFA329CB48

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00D1F9C8D324D236ED7BD0F65F5EBC4B153ACA9B5586EA073B872AF042E561F5BD

Coordinator signature

75F353695A4F5489CCD8D9449076F0C65C8D8CB11B34548722E5E0D846B9CB16189A6A879672335AD7B4CBE53457DBDB49CD3240EA986F631B4B2879488A4F05

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

D7B52439E864FFF00108F6144EA6ED27B029409930C97A5E26222BABA50E5C7EE7A1521435BEDBE981AEA15CD5BFAA5087BC5EAB3C4505F64FEF2B03E32DC109

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

510D2160D4A72975B55825A86D8D0BFC54C7699620B81B660D53F9FFDFB5D68E489234138803B05DB2B643DDEF8BD3D582902B2293552ED71B012AA02CA9220D