Type
CONTRACT
Validation date
2023-12-05 18:18:27 UTC
Fee
0.20990755 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: 0x0000BD22CD5903A6579840451F0BCD98CCD93F4366F5A8E6893717D913FC6F9772CC, amount: 18
  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: 0x0000BD22CD5903A6579840451F0BCD98CCD93F4366F5A8E6893717D913FC6F9772CC, amount: 18
  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: 17.946
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.054

    Contract.set_code next_code
  end

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

    9D6C1472DDE92DB22BBFFF633FAB3C444B99A9FA78432DCB959A9E3D8E37F303B8FA6B60C9B36579FD03C8100D84B2C3AC24A315078A4A018035A368

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000164A024E05AE0C88FF3E3388C5836719E501C08F3C04D3FDBCAD8D0BAD2ADE839

Previous signature

187159B6834192D2569DE01E3FF579F2295506CEBE24BB8F779C531F82E3EDFAEE92C41F3DC0F2A4E365D843A21DE33E4A43E6E8E09B8F9E29F695D0AC4C030E

Origin signature

3045022100D194D3B9BE58BA540BD55F007CD32575BA8733EE27471657447A3AB318DDC03002201BF4623F29EE378FA8215721B1682F35F098D0FEB6EF766BF1F4E81158F04791

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

008FD4E9A838625D82B30C0845246F45F8585484493D11099B3C94F090E61E838D

Coordinator signature

0C05F81720C71E8BC760FA1F6692A91EB3E379FAEAC039106A546AC7505EB303B26AD5E4432C9CA0313CB743830AED919277988770FC6C5AD932184D36F0F702

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

082840CD1E06D56A1DA65450E4DCFDF74C26D87AED6AFFF651CE985D61737CA9BD13E068DB89887BF96FC38F205749651F0AB2D99509B4094D7003EADB305A00

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

2D7F47AED8545687D6F31A2BBC9FB8F638611C2641B78FD129F6D6A0ADF2BCED4699A2481F1E34AE022CE349F251EA0CEB65D35111638789D92BAB0447CEB00A