Type
CONTRACT
Validation date
2023-12-01 14:11:28 UTC
Fee
0.21376391 UCO

Code (816 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: 0x000083B000A5BACC553C131B64C034EEC5A6444A69B397ACC929549161B820CB99B4, amount: 1
  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: 0x000083B000A5BACC553C131B64C034EEC5A6444A69B397ACC929549161B820CB99B4, amount: 1
  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: 0.997
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.003

    Contract.set_code next_code
  end

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

    5B4F2704A99DAD09005C12A71728DC3F9E9200D8ED643AC3CAB573BAD852D416E00D27CA4C331EC9738CF77192D969820745B1C1E8F3412DFD0604E1

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001AA32284FE3E092BAE034245E321DD38A179FA05F8930EE0F328213F8CDFEC19A

Previous signature

FD0E6710A4AB8565B1778DBEA3BB43597A016573A335ADD534A97BD18AE0C3EB673A6325B00906040AFCEE3D719E6CBD7508DEDEBEBFF43BABDBEC2E7366DA0D

Origin signature

3045022100CAD684C08B32DC706F170AB5560C0BA5706E55ED24627B5EB916CD943C9C4E7A02205D58A88B2ADDCF47E50E27F504CCC6A1099CF7042F3AD613FAF41BCC0BD4AB60

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00B43D451FAAA5DFB12B5B956B5F53E790D4CFFF727C6DF9F2F93BBFC46E401F80

Coordinator signature

E07038A3781F8B5B93857DB15C2C2803FCDE700909123C6F446FB962D224DF1472C0F836F89A5FE526969B5023E1708DDB1F059E460B3D8EE8AEB18B7DCC830A

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

B2C425F04D3B5CA86C3958E87346AC3F21A4B53D0C19A2494E34C9C26E8788836D18DB073E327141BD74A6406D95000C90FD4AF4AB0A269CC14FD846FCB2BC06

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

3783BD563461720CAD29A741CA22A0E14DA42436FAFF7E432C2DF4375A7AF5248A2A7D06108777D37F1C02B25E30446ABE0CD2B03D4018560B0CE1B281FC800E