Type
CONTRACT
Validation date
2023-11-30 16:22:30 UTC
Fee
0.20944106 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: 0x00002164D77629D9B452B5EBFA8CEF85F31CB571DC82168183B3F541D7BF1FF5EF3C, amount: 2
  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: 0x00002164D77629D9B452B5EBFA8CEF85F31CB571DC82168183B3F541D7BF1FF5EF3C, amount: 2
  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.994
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.006

    Contract.set_code next_code
  end

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

    0F39EF2C7D60CDAD9D920B84765458D0C6E6BCCE6F2215FF39B4661FA2C92AB38B5CA2C8A553B2987D31BA00317E0157CA57887112E5275B06020ADB

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000141F47B187B59B77B5606F0718FD5F70854C9CD4E6F04C3B56C0CBF89C3C4F8DE

Previous signature

003D5BA6F513DCFAC1A9D18E8C81A1ABEEE79A6ECF1FBA0C5A60A924F703ACA39AF2EEC7308E550B0616F7BD815F8672CA9A6BA1925D001B04BF9CECF428560D

Origin signature

30440220125E59563A5C1ED97A326D49D8BC1970B6AF01238030EBF20552F1445A63B9E402200A4371BDF7BCC9DAB67986993888C2DEC5B49CE5BE55E3FF24EAE017D0A3D778

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

007E8A2209DFCBBD62C320DB19F44662861DE51C845C927B412DEC032E87B18921

Coordinator signature

F849AA65B26948AA838AED16DA5E657B19205E4114B957978BABE6AFB9CFD49109E0136B0466734D437FC23BA453D993C0BAAF3EC184CE8F83199C948207B10C

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

2535456071C5EA4A2281827F0291DF1FB03D9AF1240C27899D190B21E599B4BF76CD8FE3A0B71B443B9B56EB246C1718C5202DF883023703EAE72FF19783F403

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

90B8143BF452536AD2CF488F93EFA970E758C27CEE4CBF21394087FAB0FC9EC0B885172630CFB1422495ADDD1EB49F010549829F46A2DAC713B51B444A255308