Type
CONTRACT
Validation date
2023-12-14 16:39:04 UTC
Fee
0.22061328 UCO

Code (822 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: 0x0000BBA672E26D797C80A9C4A49F81E63BF1A5E4A0BD3C093DC64857A55C5F882863, amount: 50
  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: 0x0000BBA672E26D797C80A9C4A49F81E63BF1A5E4A0BD3C093DC64857A55C5F882863, amount: 50
  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: 49.85
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.15

    Contract.set_code next_code
  end

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

    432A3BD19D6E1E27E125A15AF866FC70E57997F1243D7EF715B7F9263A1546648087909E0F6DBE80AEA2CFC05489581F936C584321C10F3B4967BD8C

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00016405230580617C64CE5FF36A2C52CAF24C171B109DAA7343A73E76A0A7634155

Previous signature

A7002E164E5112758C340F9D5250650A14B8CB49656DB7D8EDB8D43254DE9DFDB44212B676EA8DF82A43DD67BB9AF351248C017C13DAB5502716AE7CEB981502

Origin signature

30450221008B1B4BEE500EC68D0A0F5F636E1C465B832789CFC27BF5080CDF9A47ADA9140E02201FB1F52E8FD2E77925FFB83B8832F3ABD3442C4C1D68CB00041A15E52EB95466

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00490F57A1C2A961818648D5F342BC34F59B8BA5B4DCE4284C6AA84A71CCAFEE5D

Coordinator signature

CFEEDC179DF00F47383D36758996D3B1471611571E6FE18977F9200EB15007FC02E7DF93D6ADF520094787198BC22A32211887B674DB4A8A123617ED8F20C309

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

847FE62388D8B6853A1D1C3967A3B5615F7BF64EB58296370821570BB4F824FA323E11A1B57A4707EDAB8BA307EEC5916B8CEDA8228CF0B373F1E2265BCC7305

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

CED5261FEE850B05BB690BE58198BDD84FBE91ACF0779B0FF88875EC61CECFA47E587E4EF718071E807A0A5DF26BC35C9EF0A88AFF920ACF5C4CBAE4C770AD0B