Type
CONTRACT
Validation date
2023-12-29 08:23:32 UTC
Fee
0.21187879 UCO

Code (817 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: 0x00007F648E7FCFA65ED5D4F56D4E4E7A7000CB8FEC15F11D4F616CAB607CBF776EEF, 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: 0x00007F648E7FCFA65ED5D4F56D4E4E7A7000CB8FEC15F11D4F616CAB607CBF776EEF, 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

    C81EC159346600699AD54BC1980650E6676B3CB87A6397ADB21A79F243B39A1D7797487E0D7B4BE5B7BA9ACFEFE3FBD503240BFF1A6D39EC542582AE

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000167C76CFAF50F8FB52DF77AA927AC7B40A428DCB546DEB56AEDD498FEC968D5F2

Previous signature

8EE65E72CE72631E7A0EDE15E2382B9FC8EBEBA5FC906E9BD4A395CD6BAAA92F94F8B3B9387DDAD4C8A74052261932B60F8961084772079A5A3C31E2B333F806

Origin signature

3044022043A75DFAF9DA1F06DBE5783EF35BBC643A8C228FF397F3C9E68C8402FB148C5B02203A81F0B4BB7AB8F1981E636BC949C01BB7CA99AB5B876B2309548B8081484B04

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0016E6F2783000DDF1002B069D3416C72E84D7B05F1D8E52B5D47D65980A0A1B15

Coordinator signature

379A367A120B8C0D1D5B69379E487DB011D3FF8A22078A2CD490788FC0E436381D582199DCE6D4F039DDE5986243B6E0027A845B8F1E344E4B5FE87E603B5901

Validator #1 public key

00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC

Validator #1 signature

90CA2C82836E7F97E060A1165B4B719B59B7CFD0A1DFBDE2CE0C6827309D573A3AEC015105320DC10B45C2AC5D8BE00BD6F62E4EE573FD953EB6EF2764D3480E

Validator #2 public key

00011ED0B570D680BE5ECD58D2D121689DA73C46DCB38A01C6E10D06286040ADE30A

Validator #2 signature

8FC697A9CE3559BCC06E3D934E1D1F6C699ECA7FC7C0840ABAD1B31B233445A50143F12CA835830C846EF480A485FF8852E4CDA3085DC3258B913E4D65504102