Type
CONTRACT
Validation date
2023-11-14 10:42:15 UTC
Fee
0.17538876 UCO

Code (822 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: 0x0000D9E7B4300CC29670CA80010FE23292BEE4AE28057328732A0FF4CF11C319D81A, amount: 1.337
  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: 0x0000D9E7B4300CC29670CA80010FE23292BEE4AE28057328732A0FF4CF11C319D81A, amount: 1.337
  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: 1.332989
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.004011

    Contract.set_code next_code
  end

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

    CB781CD2A2438B47C242B0EA344EE86F255770F0E742ED35B19220762C6844C807E467D2486E64E49387DB0D7CD2A6E98CD078098841B165E3DC0401

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00011782341C5DD88D66C560AB9DFDFC81234DD02119076C63B02BA1825BEC935D9B

Previous signature

F8EF20EC42BBC37F97AC5495AAA951304C5537C0EBE7520F17F0BA751BF4CA64A36990DB9FF391696267A3F4E017A26EB14E10FA4514C710BF06EF3F5EECC009

Origin signature

30450221008219595AF29E64429D6B0521A4E0D316ACCA187C961BE2254F6E98D9B6E8AA8A0220418A487EE03D15B3E7DD3FE793B9D32E9B6A2AC2F55B2D5C79D63B27C24E79BB

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00BE318721F271166326EF085C70B148CDDA5FC1B02CD7E73A3DA34E1EEDEEC277

Coordinator signature

F07A93665C1D1D4D4C2980FC0BEF02D033EAE1B8F2A3C9BF3CDBE904E5087B615188E5C3DE8CA6759B8670599B5F9E1764DF1298C15638C3ECD30B2D29A94C03

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

B072DE9701BFAA3955E7FAF77C4A95A51A7774EBC8A512EA77895E6226B3B404A6C6BBF22A47711A3BD90C48BF28154297752421342D1E89592CE8B293E16102

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

A2D74BA75E81ACB99DC594035632A96960C1437AE39BD5476843743FFF7155AFC7FAB615B6FDD4F14CF5080901D5B8DBF608FBE8C96A3FC676BB2E201AA9BF05