Type
CONTRACT
Validation date
2023-11-16 16:53:21 UTC
Fee
0.172825 UCO

Code (818 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: 0x000097688DB84846A56AA7BD1AE0514CCB8F0FABD922D347F7447ED5F6714B074FBC, 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: 0x000097688DB84846A56AA7BD1AE0514CCB8F0FABD922D347F7447ED5F6714B074FBC, 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

    F89B7E127A9EBD57C387E2B3065C0CC1FDFF70B43C6BD90840F16D74CC4DF0E72DE8F805D7FE81EE9A7B9F7D14057CBFBCA83E13039AE4A0554562C9

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001604ABE751165813354E1E68D4057B5B4334503C7F6F58D8FAF30E84AC1ACC3CD

Previous signature

476C296E035654FFC85AE146AFAC0F389627E1BD3835272F96E6B0C1ADB3C246B79CD4B62F8D6BADCCE29A2ECE840C3DE85A5E3770DD040E8933D67747EA4708

Origin signature

304402206026FB3CE57F3845E8332F33A06E468414F559A6ADCBEA39BD8FB854BD4A034402206B702DE44E05BA6B30BECFF2F5C10C71646A84EC63E4C454E17BF07C66AA6350

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00EB7A07197984C453FFD1A043BB45CE7A7455F0BE4316662A9A58CCE7B1A5FEFD

Coordinator signature

D15588F2DE41CD1CB8ABD0BF1B371D1F6AF83961820830CB03E87DB854EB75C598278AFDEC92907209101761DBD5BB809DA771E92B84B657A0F40285D72BF70C

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

1DAADB6551EF84028E52CF8E6906777FEDC9089A9FB7D079953597269EE9E46097C8AE4F7ADC1A177140D92E14509BBF0CD5F08CEDE7AFF7F1518D996B8DEE02

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

C2A35A9A3DCD183EACB6EF164B382EA62027FEFF9CE2D3A21E982055A366585ABA8852867AF236A76772965DBE8D25E3B483707DA8F82DD7CB61EE0A01540A0A