Type
CONTRACT
Validation date
2023-10-18 20:51:56 UTC
Fee
0.25024503 UCO

Code (815 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: 0x00008A140026B9CA26355E22AC341F39F16EAC5A2B7B82BB468572937E04F2A65448, amount: 0.3
  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: 0x00008A140026B9CA26355E22AC341F39F16EAC5A2B7B82BB468572937E04F2A65448, amount: 0.3
  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: 0.2991
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.0009

    Contract.set_code next_code
  end

  export fun get_htlc_data() do
    [
      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

    E05A0841DF18B94A3EF82B5EB7D3F88D854A45AC62FE4A956701BF65B20E69FD2755F83A555BAC29E7F328744F089FAEA549E7D13FF352E2F9A6E3AA

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000148A4FA96D7C6153724D46D6AE2B36EF7E1EB001B8AC9B51D8F38374FE932AC68

Previous signature

75E8891F4DA317B1F6B0B9C428ECA9AB8C8B8D2C61C8B0C1C051893BD0A39C53C694D99C6FE423199246D6368FDD378D64C486563C59B77D4261C5D675729807

Origin signature

3045022100AA92451FE9D69A3521D5D7A33091DE437D04C9EC4563D50A4C0692E0EE940F8E022001FC884FF6A90C69E8DDDB4498DB34739676F9A45E7BCB16B8A843DD6AA459E7

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00D0BA21218EBC1521AABCB80230E5EE6BC8DBA671387A9E1B6667F8B868833D39

Coordinator signature

BF1F0683BD4335DA2A355B9674D8771ECFE737AD265BCFFD307028D8A45593F03A5B8D4F3CC15040B07EA31490A3931A9A9304F2D3DA893F52B1E5DB495DEA04

Validator #1 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #1 signature

6F61CE4D534D7143F5DAB325C3378E1D117DD40407E190402A7F674263018ACC71B3CE37B4AEB51A8E7DF3199EEC5945471AA7A0936BD6748734626886DA9209

Validator #2 public key

00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC

Validator #2 signature

A28F91C17331885A4D5A3A474161FDADAFB82692396E0475685E03EAE26AB90FDF973D6A7CCDCD2A3509E749E3888E4A71EC3E4C085FC4D36D23CFADFCF5B102