Type
CONTRACT
Validation date
2023-12-14 23:15:34 UTC
Fee
0.22223381 UCO

Code (821 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: 0x000091FF32902CC345EFA753C73442AE69D51DFEB86F7B65EEE054DC73882154E548, amount: 97
  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: 0x000091FF32902CC345EFA753C73442AE69D51DFEB86F7B65EEE054DC73882154E548, amount: 97
  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: 96.709
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.291

    Contract.set_code next_code
  end

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

    78BD1BB19FD336DD46B6D0D46DD80CF772131C4BC15389422E69CE8F696D71756998D6EF1FEA3BC14B29E9879AFE0340A85936784207205500C9582C

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00019156B489B628609CF0847E302E0770EA2BCA97743329244E7E6F546A7A9219CB

Previous signature

06CD744758D3CBC337AD0913ADA10FF2BCA3D95561C2E94DD5FEE047E64BED31C4B639E2A6F5EAD5EF73449F16CC02C4E42CFB6E5813AD37CCB2C1C6F2AADC05

Origin signature

3045022100C5A318DC9D2EA53EF73B9F392F80E603114F2CBD61792573739D54BAA8E6395A022002DE53C34C8A50896246BE9CA028F4F75C438E4906A088F32E43C3D617999909

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00B67CB25BB0001925CD04C3B70A95794B8E1F5174C249E93229B2325131AA9B45

Coordinator signature

A3EBCA59A0D3507ABB30F6E18B7FBC4A342C1033282C1F4F67722CB4FB22C2059A0026FE384E89EDCD431F132562B3BF0CC14BD683F65212C0D3EC51094BA00D

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

AD1130D5488E62CE99175E631ED9600C58B49E277C0719C88DA848508CC78E7DAEFDFA007EAB7042B6DD34CB07813C6907DEDC94CAFE8DE35A59ED61F5D45C0D

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

D61E443D3E3FB5D199718EE63A1034E387DECA2A30E37D8BD7334378E1546DD8533CD1731AD2BDD812B2BF00E8DADEA07BEB9CB191ADABD4E327139ADB5C7404