Type
CONTRACT
Validation date
2023-11-16 15:08:55 UTC
Fee
0.17152471 UCO

Code (818 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: 0x000080D5057516F335B1FA66F82ACCC4D05BBD983ED957B5D7D67505A4CFE10277FC, amount: 10
  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: 0x000080D5057516F335B1FA66F82ACCC4D05BBD983ED957B5D7D67505A4CFE10277FC, amount: 10
  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.97
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.03

    Contract.set_code next_code
  end

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

    01E92E59417AD5EDF378DC57B490DDC7E4FE53DC1B0C23B65B24F0D40D8F393A5FF7B3C117C84559162F7F360DFA63CCD9B697EE1B907CFA94C54D40

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001A826696BE3659042096A971055A04B4B93C0D357B226412C8D2D7C62589F4D0E

Previous signature

D3B727DF4E7DFF7A07089991C8F104EEA0CF33615C5A8B1049A47C50B911CE310B3E3DB2317586E63E362808BF809EC6C2C807556D962F479EF982E7F034A302

Origin signature

3044022012D29F690C930F6644D519295D34D6ED46B8699FA047173573D304A982918A6F02201650B49093C55430B6AD5B9B92D1CEFF7060A9A98C9F217CB59F98BDAFDE1890

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00E981AF4520ECDA8F1EAD2771F045D0C541A464BEFA8A3B31ECB9F07AAC1D2D60

Coordinator signature

298F6DBD44D18AD3AF016EF051E54BD43706BAE9E41D9573FC3CE09A704809B9212725432C40B08D290534D82AD2FA299D390784D860CE444B2C4294159AF205

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

70D63AF18BDD8F6770FF14C4EFF12CCB7F6E1A8CE793CE06047C4CFF063E44611103F19BC5B147D819F6357D85F12D5C9EC6C48022F35FC1AAA00D5D2B6D5B0D

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

402F96C814C9AA8393986D03F58B1980E5B28F86CC4E6C42653831080C3D81D5F1B69C4B1D0E6866E78A23AD40DBEFABCC64C6EEA1A6A6762E892E893EA74C05