Type
CONTRACT
Validation date
2023-12-08 16:36:41 UTC
Fee
0.2136404 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: 0x00009931C1D84FEA139BA009D084A661528A43F37321A5B7AF540050AAB5FA13123C, amount: 15
  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: 0x00009931C1D84FEA139BA009D084A661528A43F37321A5B7AF540050AAB5FA13123C, amount: 15
  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: 14.955
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.045

    Contract.set_code next_code
  end

  export fun get_htlc_data() do
    [
      amount: 14.955,
      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

    CEA635466B2E1F86D99C8F6AAF5AE01FF1B5F99C8AFB31C4D2C435C2254D3DBB64EAAA0310AE541D6C8C299B1772D60B0932B6753DE13E85F13C5662

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000173B6D807E21B78592C70CC5F700C18DC8DAC94DD57E52909198928CF89B2005A

Previous signature

D96DBE526AFC2E649F2DFB34897437B9D2B9817A061EF347D2E39F2DFB30A8C59CB0D9A57423BA4B8DF1DAB2F323AF67C382DB6937241EB51074E119A1CE2803

Origin signature

3044022031E22C8C3B4B7D051BD123207BEBFE34F6C9CA3EB249B431DC90A51DA0B10A9F022016EC9BD6FC84C51812657203FA41BFBD7A906BF8C3592737053A5A0D05A70F82

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

009A3CFD95A886F82B9606C41F6CEBC3214847D9A91D1721E7F7CD3DECB6CEAD93

Coordinator signature

0E9ABD1EDAF5F4DD5047E857B58EA79A6993703CA8EADEF8A6D7F2CA5A944A8B73ECAC7C53DC55DC73D109733789169922DD49CAE426C120D865EE0A3FC05104

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

11032900301ABEF32DC12DC33853F48A81014A61FDD1B2D8FD693AB69A8697940B937CC2C6DDCBF2D8B5C970BC6B5C5B63767F98259B57BBFAC34F5794AF5309

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

41E7712E406C3092305BF92EE9C767CB3401FEF42EB05EE46DB9D97D5F0CDA1A0524A5775DCEF6C3EB7ACE9FDCA3803D646248B9C5E9731CB9C75F369C6D8B06