Type
CONTRACT
Validation date
2023-11-16 23:47:38 UTC
Fee
0.17824483 UCO

Code (823 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: 0x00006AFF130BEB6BE9B02B80FFC13DB5EABFB0A7D167BAFC9F2DF8F141D7755FB39F, amount: 10.03
  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: 0x00006AFF130BEB6BE9B02B80FFC13DB5EABFB0A7D167BAFC9F2DF8F141D7755FB39F, amount: 10.03
  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: 9.99991
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.03009

    Contract.set_code next_code
  end

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

    08AC1E1D1B7661555FC4A1CD007A3C1FF01FCBA6325ED3F30D370519E382061E876268B21F642D7B308AFC35774BFABC12B9DD655596105EF23B6979

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00018D3C6FF10B6B7A55234F1D7359C4900103EF02151D0BE57202B4690182CDC1EF

Previous signature

30B9FB8A16E408F9895CC9138370B7FB5368D0051BFE5A51C77FEF185A6DEAC87A0B2B427D6BDCBDB67E5EC8780A80AD54E6E7F122A602C809740B2767BDE707

Origin signature

304402207C2D9FD233A6F6625C73AC2DD1A022D58A89FCA49A1EFB652B498C763197E7F3022029A8A896F7A05876B7AEA8295826A2D73E78ED5034DDAAA2F100DF8AE48DF8E3

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

003E1B1EB84C5F33991A1FB23A47D84EA67D3E11D692E8BB899DCAAC8A878F8BA4

Coordinator signature

7EE87C08A2B600F2EAD4AAA3C0C2C9909AD7122309D13A7C0B697AB8A2D1214AFBD1952DF252AB60E25D9746372294B5D50E6CD4CA4FD4417E1EF1099209DA0C

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

87ED656F2C72992E634BDE8AA96201C8AD4EDEAF048B16F2ECF038EF77FB61917F7C1C8B4509868F754007179D36F4DA220A41DAAEFB58875494DA844062DA03

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

E95892962FEB871CE3D5077B5D760B87DCCBCC1E7FD7139D592BFB9C217958436788F4693D896FDB95D086C870E407661D5CE846ED8D801619BD0D0EE5ED2206