Type
CONTRACT
Validation date
2023-12-14 05:15:19 UTC
Fee
0.21908354 UCO

Code (822 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: 0x0000FB892DDE25B9A9921DEADFD1148065E0DB0DF04DED5355F3F5F3354552935B45, amount: 4.5
  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: 0x0000FB892DDE25B9A9921DEADFD1148065E0DB0DF04DED5355F3F5F3354552935B45, amount: 4.5
  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: 4.4865
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.0135

    Contract.set_code next_code
  end

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

    83ECBB9FC093DDD60F3B7749E40C968C11A92A0F88085AC6258EE1021EE4DADFA983A3671516C398B8D6BA237E0465E90665DCE539E39BD67E26BB84

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000115541F54D17108893C0854A77327AB6B5E35382124C8B6196596B484A0A83D33

Previous signature

01BBD09D20792F0E47376CB319660A531800ADB5C4FDFC6512DE41A4E9C7A8EE91203CB2EB7C9AEF43CFFBD8086BC9C23D73A670F92A84B88DCADFA311399A05

Origin signature

3045022100FE24D835CE5EEAB62D63322BDB8396D99381D7CD83F40E365A955CDDE056BBE702204FA0B0528C789A9709EC65866169A16988625A30617F2B2001F4BD3EF0CD0C51

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

005DA7A5C7962E671AA4BB3FF9CA8BBB70C63B3078385D638CD70A5E7FD52D0C2B

Coordinator signature

D4EC0336BCB025B2A50B01268B14BE2E85C6612D50B205DB4218D10B309729576EBC9F04E566364FC2455C6262B8AD092EF5C6FD8562AD5BDCDF7B2EA64FC509

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

760CBBAFA2045F1EBEEE92B447E829E782FA4D40DDDA493B6DED65DDF7160EA9EC82CF3558348A4ECF52BDC3F826FCE2ABCDADFEAB04C8C3CBA1D2DCA1517707

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

68C87836B56540851383F454F23F7E2AA98851F3AFC0D4CEE1ED4D77D490BDE2BED128D04F10E107DC523B9BC2D5A4FB98D2F723A66AEDED056B11EB2BC41800