Type
CONTRACT
Validation date
2023-11-15 10:16:54 UTC
Fee
0.17782184 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: 0x00000BC0EBA2DBCE4455B46F5E51AFAABA6EB4C7FBA1D4E2E6DABD55DC70F9A04D6F, 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: 0x00000BC0EBA2DBCE4455B46F5E51AFAABA6EB4C7FBA1D4E2E6DABD55DC70F9A04D6F, 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

    1C9A7912FC5B1ABB40455959C39BCB22DFB6A9D673CA287B62F1AD2E26569256CE5D81C27128B6C65DD6ADE02174350FF78D331CF2A3F932D63595B6

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00019A33AB9F6C4D084E9A0B32C8DBF9F73A45576F472272899D1D45F6B313AB0B57

Previous signature

D01EDCFADC91E469BAC3EBCD44B13BAAB57DDA5EC986A7BDF0266A8DD32B12851A2DFFD38EB2D9ED5530674DD90C5A4F1E3D6143989A0425FA6BCF4889D3F600

Origin signature

3045022100A7CD938E556C8F0D9308610A56F0A50BCC7F3DC5A3A327018D68BFAAF5892D3B0220766DEB8FE899ACB4662983AF3C65810D914E48AE12B555541A1EEF7AD6FF80DE

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0048CAF2A9050FCA4984025C437C6BD33D21392968D0CF704DE8511D1037B40F48

Coordinator signature

E6051FD2DAEC1DF4D2D45810F06A179126B4E134658B9849248070F8D8C65460EB7FDBC0A3D55F6406BE7B4F813228D3431D756DE99EAC5A62C321AEB69F3F01

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

C34CE47D9CF07A9739697D72B7704F095B6D6FD5B8A715D8761E94EC043E0E965FAB9E7091F61DF0F131EA5132888B3E9C14E0BC57D1C64C31E19D5FB3DDD604

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

1B6F1287BBB7AB4E65A9B75651B0A06617B2AA2342751608D920AF1A7BA10DDDF94CDE80C07CD3104263AF514E44431A6FFCE9D3B8CAC2DD3E173542EB6DEF07