Type
CONTRACT
Validation date
2023-11-30 15:11:15 UTC
Fee
0.20922591 UCO

Code (819 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: 0x0000D05315238AD9754F13F7AAB883721AFA17F02E9D6EAFFA759E502AB50596B4C4, amount: 10
  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: 0x0000D05315238AD9754F13F7AAB883721AFA17F02E9D6EAFFA759E502AB50596B4C4, amount: 10
  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.97
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.03

    Contract.set_code next_code
  end

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

    18A44C0DAFD74EADD719C51FE64DE7CFB15E7BF61D31D8C8BD3BAEC2D76D5390E77CC9C9F9C7FFC32831C4B918691F4D11076199F7593DAA3D1F81D2

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00018EC0D95529F8C1E7CB5CFA7561459F8BA17254A8C37F95721437EC1F61B19293

Previous signature

6991A185703056DECCB37933D9C6F5616A87CE129DE3F0341F7C6539F0B35A8A09E6358F50F3389EFCA2B8210F7D57882FD4D3CF90AC8A867440E033374A770E

Origin signature

3045022100A5EA0F59EE246E1D86CC6C638A0CA32CE5A9D334986FDD94CFC6DFF14BE29B05022048335AFA0A4D00242D02A7DCF884D933394759FE943ACACD6FDFB6EAC3364AA5

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00A98545E9998A9F3684649E69ED00685A826D9E9370260417E9422BC7D0F80376

Coordinator signature

955DB739233AE2BA774383226D346EC15C0CA629CB50F25B11E8662DCD846B10831E9A8C27DB448962F688C6DE6E9891D60C8EA962F5EC5FC8EA2B200AAE9B00

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

A1ACA108D37BEF68CEAE5843ABEC3F40C6ADD668E31FE6BC8AE0B56504CB066776D269CC6FBC535A0CD48F7D675C9EB47B8844095243C19287E96B97D64D8F01

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

5BD71CC06F72998E70A072B69AB133BF9C94B356568D9F320A7EE83BBF7EF27AB2373AFD2D6563F16C9981C3DCD7D2110A683552005CDC96EA6B19371FEBC207