Type
CONTRACT
Validation date
2023-11-30 02:58:10 UTC
Fee
0.21160032 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: 0x000052DBB0394202F5E1A0290DC1595870AC160515BE80781452FCB0A205644F801B, amount: 80
  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: 0x000052DBB0394202F5E1A0290DC1595870AC160515BE80781452FCB0A205644F801B, amount: 80
  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: 79.76
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.24

    Contract.set_code next_code
  end

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

    482AE716816DC1D324520814C4BEA6336AA769327816317ADDBE8BF22F9EE2256EAD81974891A54FF0D9A2B2DDFDBAD3D4B48D2A0097A5606C1E914D

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001A44EF0133E22768BB0FFC538BE3019CFBA05164B8F68A0915CEBC8B14C12FBC9

Previous signature

8D0381EE379A031B7E4883C8B6437D2F0557AB9DEB432D2E8BFB7D1C5A519D233966B243A3B1E4DF8124713C0AE8E4E30B7CF6ADBBD29FE0CB08216AB1EF340C

Origin signature

3045022100F707C15F6B7FF54F20C7981E6EA9CE7AF5B5AEF29B12D72605C375B41924315402202798B5FA0C6D6BD9FCF24422984137BAC5DCE4180D7A0A1BE2540B4C8A9EA712

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00966E5FAFDD8443BB86FC0A9C37AD12146D4C1B94520E822FA2319DBCDEB7AAF5

Coordinator signature

6AF6FD247C9CA11BE5EACB9C0B51CF8D0ABE8B87216A24C47F7BAB0A6B092BC0B2FBA01B8D19A7CD36626C997DF0442AC11BB908094DBF3F83806BFABA9A1104

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

6FE64FB58F934A512E9EEC0FB231EF7845C43C0CBA8CE3D5D37CBC9BEE3083C7B24276EB42B24920E6D060C675797EEA15C3D8079338B6B1F2024B5738B17E05

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

21D2C2F8323412B36A893CC822036D2E32A5A15774D9F88D5C556A4ABD9C9EE010C8F76B27C13C20143F23DB59AC086CAD5FDF0CCD66BF7794B00EC1322C2F0C