Type
CONTRACT
Validation date
2023-12-01 10:08:46 UTC
Fee
0.21075499 UCO

Code (817 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: 0x000052DBB0394202F5E1A0290DC1595870AC160515BE80781452FCB0A205644F801B, 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: 0x000052DBB0394202F5E1A0290DC1595870AC160515BE80781452FCB0A205644F801B, 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

    CC3BA3B877833D34BA548B1AE4AC6C98CCF7E0034E41EB2D61CEDF01813F7BDC22383DD14B70D0C54E788FCE718530999B5578DAE0D2B34FE57B04C9

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001CC91861362AEF9B81093B0DE6905DDA6EECFEB856AF731B145398F8F7A61E60A

Previous signature

F4C5088ED84038071F270FC9C820D770820A49883A75D4E2C3A59C837E43CF380A3A3509BBCB0316602D83776106238DA87A37CDBB9AFF1ACC5EDFCC41761E0E

Origin signature

3044022013EC10606DC41BC3E42F87C926A318E7AAB4B161AC2B0499CC306873168ACA3902200C4DC055D5F7990BD47E4A408C6C62E6192BFA935779CA727D22A4F7D0E923D0

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

009B5C68C3E830004A5F974F92090A1478C746D8CADD5D2E3CEF35C742FE724DC8

Coordinator signature

5500D9C3D96EC57384BBC395114AA5762325D2CD18D633D24D00788C9C16C17A3B2C869E5912AB968EA928CC5D9FC046D57559B1FB5C8B8F2DB2DB47A66E0E00

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

AC3DF02220CD08CC40F8AE175FB8FF78837AB36695E6799E0E916E9CCDB487EAA6877A9EDA80D64F5A3113598152DA6F7032068E6AE4A1384C650EF59D5A8F0E

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

880BECCD90976342B7383B432273BAF7D5172F3F6068229214427A2FBD8A8F8B34A17950F5438B3BDC84DA95BD4089314E6F3CE75981DF266C19717DC5FD5306