Type
CONTRACT
Validation date
2023-12-08 17:02:57 UTC
Fee
0.20813154 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: 0x000075B4824AC019AC2D0E94549FE870C80E9E7B5AA4B1973EA98A8CBBEB07FCB3BA, amount: 35
  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: 0x000075B4824AC019AC2D0E94549FE870C80E9E7B5AA4B1973EA98A8CBBEB07FCB3BA, amount: 35
  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: 34.895
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.105

    Contract.set_code next_code
  end

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

    99A44DF6B28C67B5D278C3FA1EA127C404C557E47B7265B3F1BADC7A31D27DD9E4969B6FCAB3D775495579A3EEF26EE9663391C887D62EA701B30897

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001D36E4C24705DC36B17FE5FD4CEC1C1AE9E88A2DFBEB685FB0402FA36087059FF

Previous signature

9963546862074300DAE3BFE815998088204CA2A92BA296319979BBBEAA07C27E430E03B0DBBB1B2C78429ED1C41F1A7FC00582D717B5E5062C950C6FD38EB408

Origin signature

3044022053FCD3E28F00B23B6292D60B4AAC427B2192A4B1045768D574F64020D0A82E7702206185B4F26C33C6FDDFCC835EC7A3B7FEA8D5E754335FD1B29E35A5239B37D329

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

004615625437E1C4349937231A15615808D0A8477ED79BF5AB3D83105F482849DE

Coordinator signature

51A0099A08ADDCDF1821BE2734395F8EB9E2289A47291AC0F0F0F4AB3ED70B24EFD52178648F397E5113CDB2F25B00FBA103A4AAAA4707EC399D5611315B4C0A

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

5BC55FEA51C46A77BB44E572C84CDE047E68A02A59B02CF4283E0E4A267C01041DD2CB8B544F2DAFA937C49F161D45807176F647F22B410932477B83F9FF6B0C

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

F77D91AB481CA259D76C348A4F500F025B1BED4A1493A5AE50DDAAB7A446F963AFDF6CFB9D40685B9443D0B0F48BB3B5DA936D42CC47651ADDF1DA43834F020D