Type
CONTRACT
Validation date
2023-12-08 06:45:55 UTC
Fee
0.19736351 UCO

Code (823 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: 0x0000D9E334C5E1F74367E9C814F6F6DBEE370AA53B2C5236143711A5922526BDAFB4, amount: 6.5
  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: 0x0000D9E334C5E1F74367E9C814F6F6DBEE370AA53B2C5236143711A5922526BDAFB4, amount: 6.5
  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: 6.4805
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.0195

    Contract.set_code next_code
  end

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

    2CDE38CC37EEB146A3ECA08EE6D8B68FA294AFB3CFF951FD3F2F36A53804D732ED4796F98AADED323F3704D6DC1DCAD4A89F1B50365969DEA9CE0296

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001AC08066C8015F0A7B5529D5776BDCE51428829D3C95E3EA9BB22084DC464171A

Previous signature

0AD13A328BF605AC300F6720694106846A26ADE806B373D6778EC2274C216FB742E1324E48B70218003707D815B620B75006BA1CDCDD9EBA99C11A5C7076C000

Origin signature

3045022100F0C26342F265D02387787B06489FC1E2C53D83913F53227CDF7F040E2026B92D022067F49C87F55CAF009C4632E836357D425A147BB31F91F19A4CEBDD2326354312

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

002510F75F7400BEAF49E5114623E59F8C4D798DC5B9DD89C7512502065CB527C7

Coordinator signature

717461BCF30E3DF089AF11C1A70BF3FF50C9840FD823B1E8FEFBAE5AD777BF65426DEC5658765AE0C2B37E1920D05A7E87158580AB2246E406D1B7E0A7E3830A

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

7EEC3CD8B8F6F2FCF97C9EFE47F8023903F2A796EE06BA9838BEAD533EA8C3D8365D188CE984EA397D44CB553043FEF16A6125F7A4E8031E822FCE728B3FDA0B

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

9E7CE83F73C133447C793C8D04D0B8C70C871A05D29A0D4E8F51D32B03DAE0559FDD41C3342BD46C9C9D163FA5DA9835C661EC7C2AFD5076A38F55A04167FB00