Type
CONTRACT
Validation date
2023-11-15 14:19:40 UTC
Fee
0.17554247 UCO

Code (819 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: 0x00002E23104F83E325686794C2D1BDFD23CC04566258C9EFFF6F35A34231C558CD43, amount: 100
  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: 0x00002E23104F83E325686794C2D1BDFD23CC04566258C9EFFF6F35A34231C558CD43, amount: 100
  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: 99.7
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.3

    Contract.set_code next_code
  end

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

    F1F216FFFB14AAA9C8D5469FB18EF3A48182B3D9DCBF72302480D65DFCBA54D158D461A4FFF6E83EF54480B86A80EC17A537E0A0973601E36E11F85D

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001CC04CB6BF7B3169127C6CBCFC664A3B44F9EDE0A85200D219AA417711D478F7F

Previous signature

3DE2DEF1C4223BFD2707D9CCFB975592C0596A0AC6C4A61AF2826AD90A76B36BEFFCB91FF8F312FDBDB182C998AEE8790DDFDA5C10C9971FD2FBE331EC318B0F

Origin signature

304402204B33D7CEE2E90454EA67EA0D7D770AB9AE0C7D3C83A48D478FCD7DA07599C92C02201ECF29C5FB4F38D75CB770509BA51733A9C76547352EC0F6D12F01C45917C188

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0038FDC4B3C37EC5551EC5C3C0F9B3B6DB2B97C1FB90A13D9F44FAEEF10E193886

Coordinator signature

78AE0181A11B07F3DE789BDD050F5E19EC0F3B6F8410EC1D30D318234009DE9FCC3FA39C88D3B9E88955C0A09062E636C9B1135509F249DA2E3ADB01CEE06C03

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

6351910908CB476BF4ABF040E2CE7F0915D34342D342EA25F4EC9FC36A37AF281A473F7E3F56B89BE8C185BAE65A938DB4FE42252152739814F213A68014B905

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

F2E72F95393E0F374411785C80EB360CA237F1718DC8DE2D0D43175705388120C7DE9E67B53E48549A9E3ECD03493587DDD9025D09F52C36878C8AD6471A6C0B