Type
CONTRACT
Validation date
2023-10-18 20:49:43 UTC
Fee
0.25024503 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

    D786F33FD952825276B91FE13DF6903279A3C3FDF1BECE1622FE20A54915518123D30B2D5F9BEAE75E6CCA6FF5F6F3C35EEE5D7FE67D3BCFB7894F09

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001C8A4A2D0F3059DD3920A8DB794181840685F6B3216A1A5BE372FA78CE0819413

Previous signature

B0EA45E7BD06DB974B990D2007FFCFFC8B089B06CC2FE7B8F5B4CCFFC39F194C3FDB489056530774E991F10D57705C5DC68D68D28D41886A3472619286C15D02

Origin signature

30440220643E66E3470C03F9F3DE8C9D26A63B7063D479BC7CF42371342E05D81D062DB70220316963DB76BAC1B13D130B7AE4404C8A1BBC6154D61BFA794FCA7E8800F432FE

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

003682F78675BFE569E55BF0BE723768C72E782CFE390A148D1F1527EB2BA567DF

Coordinator signature

14CB992AB5C54008544ADED6F63B25E6604F0CB9476748690E8267DFED1D31A43AF20980F3387B19B3C3523F3A18B7874BB72A56168776DA9C204A658EAC7D08

Validator #1 public key

00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC

Validator #1 signature

C54767CD91DDF762A98F64A2864D449E551FCD2D19255B32023816463BA59C5B907634B0462520CAF2B3ED2E6C5A4FA809539019E603B59E0BA41F869DAA9B08

Validator #2 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #2 signature

C5330E282DA99E3D9A1635E5B733C7895D97BB025EF91500979447BDAEEFCF1F5E2E7F2D591E705258445B2C9049608E8F1C2F94854C3E4200CA3292EF3BD706