Type
CONTRACT
Validation date
2023-12-18 17:25:40 UTC
Fee
0.2334234 UCO

Code (821 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: 0x00003EB4B1FE2A1D3C913C33FCAD6642186DD2105DE10807F0C3117E588DD6341742, 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: 0x00003EB4B1FE2A1D3C913C33FCAD6642186DD2105DE10807F0C3117E588DD6341742, 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

    89A760F5CCBE6A63CD6B2FBE5ACA91D654846837CA5C57226187FE7BA14F3CD99F8B85CE137A89E4AD12E633BE3B4423725C4A3BE9E73ACCB504A380

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001770A9E31999D67C15D8261FDF51A582F2620B83657233F458301812A1B151D0F

Previous signature

561879AFBFA3ADE4987AD51FD42427B7A70A839E4DA12B17DCE711D3534424A3E72F202BE8E710B851EC32DA1B823CDF77141D1D7CDDF2E541F1281770C84408

Origin signature

3044022028AC270451523D8EC81ED85E41928489EF3E4F67CFDFF49884B7205147ACA74302205F53AC4D759C2CCDB325BFB2E55DCF80143231EB12E4D3737C7F03C3E918F634

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0021A51B3B06A01CC0E89C3290315FC8FE8F26FEC8514B7DB3E5CF6FA8ABCC79F8

Coordinator signature

13E766A09F413B2FEA9E283B1CB5E49F31BD5D3CAAFB6C5FCEDC8DC9E653A67628F99C3B27ECA1386E3784F05639182EFB61CF9E8EC019287F284C851B01D70F

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

6D85B1A9D6C298B407EF63692F3C837F013C91D305730F6443DAA84AC319280A86FB2AC64C7815F04346DD9F03FEC6FD6DAA749FD3D4FD174343F88212E5130A

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

EF77C73EBDD0B931538F1EA154AA8F84CCE81E32B73E75DBA1607EBD0484E4FED001C98CAFEEF55DDB72F5CC94A5B37B17E49EC8A78383ACF6D078A5B2867F0D