Type
CONTRACT
Validation date
2023-12-11 10:19:19 UTC
Fee
0.21967042 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: 0x0000D0F67DE669C8DC266F1BA93006ACF78837487C8BFBD762BC1C3FD0E45957B715, 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: 0x0000D0F67DE669C8DC266F1BA93006ACF78837487C8BFBD762BC1C3FD0E45957B715, 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

    B39B25D3637C791B7F9DD6327C868CF2A63BFA48CF97F6D4BF3C7F635B5A0D6135AE9F5F3A974550A6C8299E25D57495220E78E10120B6CF6139A8BF

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00011A81BEDD3D47527B9DB53D1AFE96F9B778CA2537BC085F79ABD384961793ABC5

Previous signature

A0215E4E55DB70625E831297084E7A1CBA3B4AD5D819328BC55242D15EF7147895F1C5D755DB21B61E160216F90E0F0779740B8D8DFEA3B20E772768765AF505

Origin signature

3045022100954A7572BE0F12A2EF7B5B9B6835FED87B84029B5993B5598C72A320B3A431B302207B28F8784F05761ADC882AB969DDB9A0FC61971071D101BBD041E67EA1877F1E

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

005165EA70B93EE948CF61000AFE552296C11EA2377A65EEFE6D80521CD0A9876B

Coordinator signature

AD62A2634DAE32F2CA409EA80B551C448A099240A545374CE1FB6169EAE2FF44959C8B4E91BE7CC3FAB8532CB8D0975370A2131E6EAD1593AB1DCEF5B383AC00

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

FB728BF7444714596E3B4C70C32605229E5F7C7FC5678210E98AC4CFF48554593CC09861107D182C8E6CAFB3EF5D7D87D8DD1EBDF1B069CF91A35513281D100B

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

225C4A044B9D130B30870B4959AAC7DA3A1E9674F0B0EABA7DA3BC9EDFE490653FC56F5395BD26315581DFCBD57C206FBB60B95B790C5D67E523178038A7A10A