Type
CONTRACT
Validation date
2023-11-12 15:52:26 UTC
Fee
0.17092677 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: 0x00008DD40CD42287A3C8282065F5BCA7259AC7014CD73109B570E946A977687C7BD0, 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: 0x00008DD40CD42287A3C8282065F5BCA7259AC7014CD73109B570E946A977687C7BD0, 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

    79387E7E9AE6DB7C76CD1208E37F76F27A105B92993C6040A3269FED079BD8D8423F9E116F07C748583AF398461A4C87F2DAA04B1D517444A72AB528

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001B76D70C4F267919647C70E465215F249FBB47488FE1D9AD870A55606ACDDFC7D

Previous signature

F66A0CEF509BBB7EFA88EAE22388142461F4399D7C350A3F8F128DBD21AB2C0C91C2EBDADD30C8AA8FAF61920DD6B650D656508235AF72844DC6626D03B6FC02

Origin signature

3045022100D8D961492AD93E6C5E3A4461BED9A2BA711B866C0ECF79A73F32430AA5CABA1702203E9C93CE26B4FFB7E560FC9A8D51AA846BB75E7A3365C5AADF0803537EB022D1

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

009A78EB657AE8C9B704D3F63FFA69756B49544971F7A5C0A6AB8DA10310E5A134

Coordinator signature

2F8884DBCB865D184311F36C8C284BD60D930B5DC227933F9088E11B1813478DBB886D644A95C89D3DB05BF782555A8F7EB5F99DA2A463093B0A28F50483C20A

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

0832201BF8A4950CC8B58AD3A5BF20DAC676BAB00476CF4EE4E484B6DAB6E4AF011A1A447F609358D0D505516AD845679BAF3EF49E15654A36327F3F6F5B7F0B

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

20F0C58212B9929724A9021FBAD135BC3EFF405F325AC85466325A474021D4C7D4B20CB5278D771CDF4BDB568607B8E8EA34EB1E652FCBF65B74750E62967903