Type
CONTRACT
Validation date
2023-11-16 12:50:43 UTC
Fee
0.17472631 UCO

Code (824 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: 0x00001675BECDA24450FAD82114A15B58567979E8E7AEA1CFFC54CE8C1779513EA2AF, amount: 0.001
  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: 0x00001675BECDA24450FAD82114A15B58567979E8E7AEA1CFFC54CE8C1779513EA2AF, amount: 0.001
  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.97e-4
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 3.0e-6

    Contract.set_code next_code
  end

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

    A9C5848E9D3ED8C3F15DA9D560A65813CBBB2559686E8B2EABBB62193B3A89B07D65C03C1426A993C02EC93A130C0C005C26B622CEAE93D11860CB45

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001C9E679FA49A5DDA7239E8144861FBEE2EC47088A08ABAFBECC46EA7E505CFE63

Previous signature

5337F8FCE85CC3C152FB83083909474BADC9C3BA2B5E8EFC640B52905FA754A306B3226A7DE50B0C24AFE92BB496B773CC93A4163BEA634F63A837390F11B004

Origin signature

3045022100CBA4FB973B738322F0B29C37C7925C227C253C6ABFB18897A15B6A5E541E18600220581BB4036DD79B27AA2C4FB11472D2A4FE7821BF8602D8F12DA7D03F25491065

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00A2A68C8809609398955244F00C5D318DEF2C65CB20F8F5041FBFE08B37805EB2

Coordinator signature

35A297F101B0D6C1C2E45E0D6FCE3D1184231D83A282854442095CB632E49D3877F8BC096A02FB4E09B21DA9E670C18AEA2C7BE2397990AFFAA6F8884E41260E

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

1D1072DE5B8FB92466610EA74F2372260CAC034EA96EB14584713DACA566F43BF2EE5938D132B89133FBEC0719ABD4F62317DD1775BFD8DEF88EFC1AAD1A8303

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

71BC8013BE7F8895E2DA4B262D976C6B940E1A5519462D083F97E26FE23AE922943D655C1F08749D84F83947A744906599F11DC2C58894DE37421CC1510A370A