Type
CONTRACT
Validation date
2023-12-09 16:01:42 UTC
Fee
0.20504019 UCO

Code (851 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) == 0x00008DD22E7496E86901E9B276A1BE6F9512EB09980CC04C7B76495EF37D5666A709
)
]

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_token_transfer to: 0x000066062AE51C8EDDB115B895B4917CF9A25F20A0CDAEEDCFC62085AB197F6B48FC, amount: 1.0e-6, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
  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_token_transfer to: 0x000066062AE51C8EDDB115B895B4917CF9A25F20A0CDAEEDCFC62085AB197F6B48FC, amount: 1.0e-6, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
  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) == 0x00008DD22E7496E86901E9B276A1BE6F9512EB09980CC04C7B76495EF37D5666A709
  ),
    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_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 1.0e-6, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
    # Transfer fee is less than the minimum decimals

    Contract.set_code next_code
  end

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

    75398C87E19A79750F03E4D71632727129903C439DCC0B9734E79509D97D6B2F2E8C74136D508E2286605F079C276803E3EDDDFA780D4C58F47B8EB1

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001ED2C2340492B6A4384CE7A3832EF046AA15302A3799F70D7A781248E96FDC04B

Previous signature

3B882F400E10541C061F068E63F2D0BBD48EC440C6B984E6A2F00D5AC7B7627148D9727D0A0A66D608F04B6035F9B303FB84BE7F19C9720C26E5CB4431313902

Origin signature

3044022064ECDC8A86A1A7CE96EFEEA25525D3B0736574FEA6E0DECF9B122BFF53BCD6400220050F847952C37AFAA285E718597ECB532D47D6472B489E744575029FE5F7834A

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

001839D84E243FF9826841231D9FE3EEAA8803CF9852D199F3F0E3BE0DB0ECBA41

Coordinator signature

B6D50620F023C3FF2C3527FD301B702D24AAE95A1398334D4AFEEB9869BFA69B39FAA0EE35E8C0763C15F30D2171B9C5DF628F754F395DB28BDA1CCC1CE8EA0C

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

BDB6A32EE44675347E875027F2885EBDB91490B956B0C78109CBE9159790032602012C6821964D6A2FE97C3BFD51EB26E0260CB1F52D3D4FD36BFF484F8C6F04

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

289789EEEFAE05297B8202CF1051AAD5F212D441CE56F8E88C871A225834C54FED44A502EA854A5682264A53878CE8C36985B62D9DF361942107E7368DFDB402