Type
CONTRACT
Validation date
2023-12-14 04:47:40 UTC
Fee
0.21902077 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: 0x00005A2A9F6A89A632B5E8E9F07D0BD4D2C6B054EE82EC98DFCEEC187B124147E354, amount: 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: 0x00005A2A9F6A89A632B5E8E9F07D0BD4D2C6B054EE82EC98DFCEEC187B124147E354, amount: 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: 4.985
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.015

    Contract.set_code next_code
  end

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

    4352E4F8D24E7CB38173C21D6D1280B0D7C52E2B596F93EE41BA7946B680908F72720AC1A25E2C48343304A293D05E47F89E78713012E187446CDC29

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00019036C33EBE809828FF5523DF233E3217235798A774778AA7D24EBE8727A8BE08

Previous signature

E9ACECF9177FA6E1A0206D6E8CE7EDC568C85B178AC4B89C521FA86C2C5C25B1BC5895B5E0004EABA790F683EE7CDE93B7E20E5A83615A92C33EF51E62FAB803

Origin signature

3044022074767C2A794775737E8281A994A1945C01D4DB769E316AF7A5E08372DF7EF9BD02205B3EECFF78764B173489D462E635869774567AA4922C7E8940957FBC675DD8C9

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

000F1C70C6A4B3644EAA830A734DDF9DF6E348612235598B0E2180DE94A49ABF31

Coordinator signature

9B685C1DC1E5D2F266E02DB9F3311FB77B4EB7F7DB567D6DF09CB523FFFA4B0213240662CC43AA8ECD94D988659917A947995DFF46DC81BA68A5147AA9052E07

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

17A75E604F15BF688BB4744613EE16E95C5614F2368BDA4B5C37781E2A59E86156D94B12B4DFC3BBBB045B7FF283B63197C486EA96112884AF9C863E9548D504

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

1C42DAD24712782F5602DE93017F496972B21384A78E60CEE8A62DB1D5F506FB113FE771762F640D5E89B02A3DC4C3244A54E5F033C726266F6B94803B163F08