Type
CONTRACT
Validation date
2023-11-13 18:15:57 UTC
Fee
0.17265069 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: 0x000024EFC168359BBE0ABF897270CBFABBFF5784622EA02A463BA2EAF7C5219EAFD7, 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: 0x000024EFC168359BBE0ABF897270CBFABBFF5784622EA02A463BA2EAF7C5219EAFD7, 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

    2B9FDF4D19E33F9CFCC1FAC5E6EE8DDC4814C8CEEAF857328AECC24CB13D270C6CCCAC701D3B093D638BAF4C16F42B218C019B258482DA1CC974112B

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001D86C695FF8DC9669BBD4419B47F7D08E20C77402EEF9D946DDF5F4F7745566AF

Previous signature

337958C9EA0B0FFC204AB7A42CCA257188BD747568333923630739881AFB265CDCEEA1AAB9334E1A8CA4BE925D462C84B0F572B1F03241DA4588689346C51B0A

Origin signature

304502210087CA3CCC870A966422A0067FA7B502088A4F1C11641C525CC1CD3BBA01EEC86402206B1DDE2B28D05E7CADCDDE2C7CFBB52B003BC22698AD32DAF968775597F79894

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00DF911109AB686A8A56C6D6CBE27412C902F681CA01F2429DEDD2DC725C90B75A

Coordinator signature

2D1B7705581F584C0DAFD1EB1C8EEDE38805BF6349FE28B8102A8E3E740C40DD022E78397C9D707B8A8FFC8B39AC8921C11F96C1DADB7DE2FF204B6061E5DE06

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

666BE94EE04102B619FF7DA0D94DF24AE936065ED575EBCE867D8706C61BC44DA435CC8C0AEBFB8B6845BE2F0936541C8C701D92EC32CCBE16C0A15B75803F09

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

BD47FA3312FF98568AE6D26A148C3402054E87BF1EC58A6CEFB9F55C2F9211C4067F7EB1FF1910113C6FBC24FFFEC8AC1A7A7C9D60E72DA52237252964B3760A