Type
CONTRACT
Validation date
2023-11-21 16:14:32 UTC
Fee
0.19052105 UCO

Code (820 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: 0x0000647409F94DE9798EA91E049B9AABA07B8CF3570A22056513B3437091C04B6807, amount: 2
  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: 0x0000647409F94DE9798EA91E049B9AABA07B8CF3570A22056513B3437091C04B6807, amount: 2
  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: 1.994
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.006

    Contract.set_code next_code
  end

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

    0658AE8DFFEC17A101643C6B7880B6AD0605584306761D62CBD6B5609B948DF933DE7C0512FB742E2DE117EFBDE267A839FCE3E0957BBC450FDB5017

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001FFC7AF354F36F1A505E8E22325B5DA6B4BD9EAFFF2B0C4F715FE06928BB82E03

Previous signature

8542C8C741F52F21C2CCD4AA0AEF5856D7320AE75C4C6D52BAEA6677F9413AC7F9A2FF50ED8B2F2E92A439CE33A9124D7B7FCA7FCC6FE0CC4DD1750A8A9C7504

Origin signature

304502210092C0BF794DADC28B990F6CAE3C3774DFE1F180C0C8C7BB45FE7B3E0F3D3C36CE0220301DACBDB5A0C27F5474B583583ACEC3E6204F016AAEC24CFB2A17A0C1A6131F

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

000EE38ECDB5A1B4E64EBA16A7C27078871D04F8185AC0A1D5AA5D7A278285499B

Coordinator signature

443F710995408E877CFB29D16C83CC3596AC99A39914A20BF03C7B2556C1FF8C4BDCDD8747AF429FAAFB1814F39FBCFFD814A05F426E8B873E18D7524AA4B601

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

CFFB57095892A59E9CB4CE398576425E32823B10E1C00329496C5A5C964D2307FAE981AB10887B831D135BC28EACA6D76C27415FE4536C0E637C9032EFA11904

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

86DF8BC052D4D1B79C20934065E862C118863F2B3CB7E884D7793C40921376060A0AD9F447E2058F567D0640D1BF4032A29F6BC21024C94ADC23D4C941C03C08