Type
CONTRACT
Validation date
2023-12-09 08:31:15 UTC
Fee
0.20984893 UCO

Code (831 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: 0x0000A13340CA5E06989B6600C5B84FE8CDFEF4CBBA34041203EB1FD0DB386A469337, amount: 13.14028866
  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: 0x0000A13340CA5E06989B6600C5B84FE8CDFEF4CBBA34041203EB1FD0DB386A469337, amount: 13.14028866
  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: 13.1008678
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.03942086

    Contract.set_code next_code
  end

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

    BCD1F80241E1F8FB74E5CA0813FE3C50184AE78692AC0A0D415EEFB521675A0425B00A4B651AC74BBD5CBA9500A7482C68338460641B6A28BBFD49BD

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001A46E2D52FF7EE7E391FB68E814CB93D782A3596C791321D7623CA9AFCA02577A

Previous signature

0414753998CC41A494AF1990434E88E1CDD0188CEB699AD9ADF115AA34FE86CF989B6FEC39A9DFAF488C75C0FB5078D2102DB0924176AE96141DF74589C7960F

Origin signature

304402203D32F9DF4337A87EECD5672D5CE48A3EFAF6D320E0313020E706ED65E824ABF10220377A2E036FE3A8106F899B791E5EF2FB43E9956406EFFD70D49C16917325E084

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00F94D0AAD6A1538DC389CD21C3F4C148F10634914DE421C73A48342E4E548E2A4

Coordinator signature

A331C465F228F64B4B573B12FC64886692A5CC6F88EF79AF7E101CEC5C6DF71D3D9A9B672437CA06F529281E84D854CF193311C5CD8309AFB96DEA1854F8FB01

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

437A4D7679AF631DFB376967A30A0A7F0CFF2AEA540471BD15D07D5FD3418CF86C7553576FA64A544590A9809E9C09D24140E2CBB2194A72BAC9A761BE992D05

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

5CB4769965CB534C2E845F40EFC9C9C86B21554EF3A3C45BD5B410C6278CEA6974EB366DC070F7387A505DCCB6606D23D1C993EAC49DCD36123503A5275F4C02