Type
CONTRACT
Validation date
2023-10-18 20:47:43 UTC
Fee
0.25055574 UCO

Code (815 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: 0x00008A140026B9CA26355E22AC341F39F16EAC5A2B7B82BB468572937E04F2A65448, amount: 0.3
  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: 0x00008A140026B9CA26355E22AC341F39F16EAC5A2B7B82BB468572937E04F2A65448, amount: 0.3
  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.2991
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.0009

    Contract.set_code next_code
  end

  export fun get_htlc_data() do
    [
      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

    6B7AE4AB25272FB8E19709723F12BD242259C59C7DABCD455D111857FF4658E0E8A1C59EE57FD21113DA21583CD5C26D60322423D0EBC848B6E41B26

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001B0EBB692C037B177009AD4A94C4DB91F52C386BF0AAB1D1BD562427B8D7E42E1

Previous signature

A90159DFBE4D33BC083F574AED77DE1CDFE4710B70CB583E87E1B3A68923B944E21A1CF13F5FE0E2B326138A2DE7FC7DBB0596305A8165370FCF02113EE40C07

Origin signature

304402201AB62776F2AB55BC576C4AE0326120A7852D329BFFC88B1922C222CD9E4AF257022074F1E26EE46078532D586F06D0BF9810C33DB22020861847EE63CC1B859BBAD6

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

000A5905C2547634814B0F4AD3B8DCB296C87A5D82D5463FC001B83496F2001F96

Coordinator signature

C91602D4305CE923936CFC3812FB6BE7A1D744C87039B569AC49E08BC65F439562CD31B0C3381C83668B5F8C274DF0D9CF73ED2CDA3ACFD1DDE5A5365411C80E

Validator #1 public key

00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC

Validator #1 signature

F5168C02364725D68A8C23C4CC26EB38680EBC1C4171C5C672EFE72552EF1884EC09E815C84E847DE55C0103718E3B6DA486662D7E26D4879C160D8CD2F74002

Validator #2 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #2 signature

F484DD3DE15A0C24E90FBD0E47846DE4FA828D8584511D2DF605B596D21F54FD0D2F90627B1CC52733DAE4BC8F8FCF9690C7F13EBF6F0D0AE15EFE7FF6EF2D0A