Type
CONTRACT
Validation date
2023-12-07 11:50:59 UTC
Fee
0.20411082 UCO

Code (823 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: 0x0000DF6477CC7E206F43C4D36CB5ADD35BE5C54F29ECE86A4A34AFF5F3B7D6728A9F, amount: 132
  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: 0x0000DF6477CC7E206F43C4D36CB5ADD35BE5C54F29ECE86A4A34AFF5F3B7D6728A9F, amount: 132
  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: 131.604
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.396

    Contract.set_code next_code
  end

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

    B043B216D5EC0381A90133DC6D505A82D2994D7379C8B2C95B8021B6FB5CF2E652315F9419D1DADBEE7FD465732335F880E37EE3DBD4B55B6D8446AA

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001CB8351CF365CD81743A1CAC8F805937ED69805DA7F5BC25A2676576CD9153378

Previous signature

496DAF45B3754FFC0C59B15BA5C7E4191E1B71CC6D94307D4B95BF5657C7189C745FB837BE881547F79E81035E2DAC4712EBAAC842AF21BEC50E5FB9825B4208

Origin signature

304402201F45F9103AE40A889F5C8F44F1F4EDF9F4F63751A6492C1A881DDED2BB152D950220256DD8CF0685DEAA50F3CD3B07D7AD671AB750BBA0BA95850ED806F54971C55E

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

009DB540EE9700292DCAA0642C8D583B5B56A90C35BE9F996C2BEA582CD7B3D23F

Coordinator signature

7B2C50381FE148E88CB81D4818195490352A5B317BD15AAF816D7393707EE76602394ED1C42F55EA31553EC3CC46B1454D616F06600DC49AFAFA4471640EF40F

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

C0F284B9D86D54A9B4469BD7B1D026C300491DA411E41928FD2986BE949C82F349B693F109B0363AC9A5D75D2B38C0542DE7BE63105216D5E60958174D86030C

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

2D190E03EC60457BA2B4E67AAA3AAFF60D2045AF4CF1C12AE2136A12A97AA812066C092D43589CB1405A72848D6604B4C2F0C53490E3119815F17E86B1A85E02