Type
CONTRACT
Validation date
2023-12-27 20:33:51 UTC
Fee
0.20490301 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: 0x00005D06DB725180EF960E71D5F2F6A6442D96FC89197F64C3589F0A1ADB22430ECF, amount: 100
  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: 0x00005D06DB725180EF960E71D5F2F6A6442D96FC89197F64C3589F0A1ADB22430ECF, amount: 100
  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: 99.7
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.3

    Contract.set_code next_code
  end

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

    1FF09BCB96C6A2DEE7029157A77F0053F5B0A644E03A6C0C0C24E57106B941207664A94FCB419DEFB7E8F033E8A1D4EFC148C743ED302D8B94213B0F

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00015A2CC23A3AC9B365FE84626931B83637E4A8B0345DAABC84B5030D0E05970104

Previous signature

E28EF4BFE8B2FF3B6A963281448ABFF70E93A546904AAFB012811C4035A7E26024354E0676A8C9DD5657307CDA50DDF706217E8B56F320BD3BF337C449B44F06

Origin signature

30440220196BBA3E07FFC34A5BBE813B0CA6D458E75BC3E8229331D252F4ABE1ACF36BA1022024CDA09366F003FE1F2A2AFA54E7EACA6291BA8F60C5C5036C9FB8B5B4BF9A9F

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

000A226E334ED6131A770D4C9CAF3441C4F218F654491CA0664EEAEBE89594F92A

Coordinator signature

DE0058DA540333B2C6CEEB8BFE9C73A43D7FF3A973B9454583A2EB0F29C96DF9530B52F426C4C0F04A8E56F203CFE2DCDC181212F2BF3389F0BC0130C8A8E100

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

81BF4D0DEB9317251FFD858615CDA86CED79B17BCADE41C5E8C539CAE23C300A0E98041D8ECC9C821B80C356955308177BCC70860767EBC6E2D984825AAA0D08

Validator #2 public key

00011ED0B570D680BE5ECD58D2D121689DA73C46DCB38A01C6E10D06286040ADE30A

Validator #2 signature

89BC9056C49311CD4E162ED1216DA9801906EED801F7DF24FF2BAF61C6597FA1C057E92B6E57B6E403545FFAEDAF5B8E04EFF4742B6DDD0E26D1428180226007