Type
CONTRACT
Validation date
2023-12-11 06:23:04 UTC
Fee
0.22382972 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: 0x0000B3757ED1AFEFD40EECC9D20EA8860B2E818292618F6F5E65659EE993BF0EF1B7, amount: 5.5
  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: 0x0000B3757ED1AFEFD40EECC9D20EA8860B2E818292618F6F5E65659EE993BF0EF1B7, amount: 5.5
  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: 5.4835
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.0165

    Contract.set_code next_code
  end

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

    C23F34BF2204BF5B9D156DA5AAA48D8E5C5340665AE11FC59E6BA7821DCCF23FD663C9C4E17F6B403476393345FFC4CB52F28D321AA5F8517FDAC917

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00012F9CEB5CBCD4F150FDA2DE0E5087FB4CB8884902AD9D5047B661CE62EA5DE3DE

Previous signature

E87F5D7C0B7A8CDC1AA4D23BF490B8902E2717C0BA3180B08C85C5AC7F1D1994CF9952AEA5ED12AA95885A5F39B60B01300539C2DDC40C91328B3B314874B30E

Origin signature

30440220310EB7A356D2B2004A9810D87F8A80094BEFBAF3BB324206DC860D3CB6245ACC0220656021CE549A9CF2DF86AE5976CD0FC684FD967CE5C82F691A4153961E5FD06E

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

009A54D154104F9CD3CA12DDAD3AF19374CEBBEB05AF8CA6B06470FB30527B06E5

Coordinator signature

9C8668ADB512B6A9D3D11C11893384F2D03D7B7945F7C951E8E0359422390CF829CEEB49B9E0C7BC3E03273EE8FE078A583715F40D1FF34479A8F2CFC064940C

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

550BB10CF370A0472EB3DA084A268CD5ECFBB6D086E77FFCAC8E316CC0FF8D32704FAEB57F4DAAF9961D4EC9124085AC913C38EDA479C6E6F571C40BED3C370C

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

F18DC1459B8C55956218B12DAABDE65733F0019AD2A9513BD6093CAC6615CB6104617A91DF83440DA092B806AD5F9A1B006B379E97DB0BA35D2B623EE084E70C