Type
CONTRACT
Validation date
2023-12-01 12:53:11 UTC
Fee
0.21411606 UCO

Code (820 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: 0x0000521BC149B64A4128DF7AB9C179E20DC0DB2A5FC2F1B0E43EE817D9D9CDA03438, 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: 0x0000521BC149B64A4128DF7AB9C179E20DC0DB2A5FC2F1B0E43EE817D9D9CDA03438, 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

    EEC329B2B2D4CE4F4AD7E20C11C716F611F28DBF2E2C5FA0F4DF5B58C93E0B9A6A8B87C81AF2E0F165441A5B1B9A3CACE15DD0A892492F59FDD50D19

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00018F763089A0B5121546413EF0524179A57825D97AA732AC49CA68C7B986415143

Previous signature

7A2498C4E0000CB04D1253DBC9591E0679AF213DFC7ACBF9EED137F57CF42892913E603A4E240CD44801FF6E5E90CDF8136FF2556E896CAE75AF187059534E0C

Origin signature

3045022100F4075F0E93C8E69345B05E9D91796227BC370FCA553562510D5FBF723BF6A7FC0220717AB1DB65C10EAA8E381BB982B969EB72181DD6932862E69F008C9EC79F191F

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00C36B4F4B6CE9BE58A335473E726ECE1E1AAD2B62D1717B78DCF3E29567D65495

Coordinator signature

B668C50623478D4617DB38D1F61862F7DF9AEB2834A8B2C29D4AAB647B153F5A320269FEE2A657DE2CEAD124DE2BAB288DAC62783ABB38375D86936BCC3E7308

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

0560852D18F7F38FF68E017796E5F354D0037EE85157DF90E645478343ADCEE246261CCA2ADB69633AADCB517E2502EA6A0AA371881E3AD42DD1DEFDC5886E0B

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

D77404D2E687F07E49AEFD88F6E7300D44053F13CE88A49034ACA2850124DDBCEE890B4DA475002CAB704C961A6004B067B5FA6C313790ECCF5D574DB8CC7D0E