Type
CONTRACT
Validation date
2023-10-18 21:17:35 UTC
Fee
0.25062021 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: 0x00008A140026B9CA26355E22AC341F39F16EAC5A2B7B82BB468572937E04F2A65448, amount: 0.01
  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: 0x00008A140026B9CA26355E22AC341F39F16EAC5A2B7B82BB468572937E04F2A65448, amount: 0.01
  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.00997
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 3.0e-5

    Contract.set_code next_code
  end

  export fun get_htlc_data() do
    [
      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

    29D2DDF3CD532F9631ED5E56CF442E674B7B49374788E2036257D4A5110F50C265649B5703EA2B5114FEA4C0A54DCDBE619E237BCBF7CE63173F7BCD

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00017162B31FAC1D26E394084333392BDB845A171EF87390AE2B68CDDD1E148C2A27

Previous signature

551CC866800CD26F17397A971E2E3A1DD1BD28DADC988CFC0DFB6FB198A6414F48A411325313A380DAFE3BC35D1FE869959FD610473C9FE59B106F757E1D0C0D

Origin signature

304402202F6903D92CAA6D4938C5FED2436FEB06026C85440284D6F75B3680486C10F22602201D48AED402F0B47C5A9287A5865476E0E73F09EA59265C18F5E197D1FF72D006

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0019010A65D4FE6BCB8C8350CCDD371506A5ACA2C07DC8DFB8A3D58057F01327AB

Coordinator signature

89E05C7BDF6CEDD05E4B80EB37DB8922F5907668D92993F541131EBB7D84A32E13885A786D2780BE5FC6AD8DEC66A3E6FF57F89CDAA8CF8F1D1DDF2622740D00

Validator #1 public key

00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC

Validator #1 signature

73BCABEFEA4C6E693C69F149AAF1B2F303EEEDEDCA4DEC8CB93171A0EA8A639C4E5E84A23DB3CCD430403370A5EAEDBFA0C53F197188D496159BF42AE3490403

Validator #2 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #2 signature

A20D64B408397B8073EDDD77DFBF168F2F6D4AE84662089D6EB397703D668C8EE91FA76A54280B20994401D0C74A508A08FE2B3541AB01313787BDB54FCD9303