Type
CONTRACT
Validation date
2023-12-31 19:51:07 UTC
Fee
0.18617949 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: 0x00008325C7AA50D376432DFCE06E983FDF9B99AB36E705CA9AAF9737CA5E7844BB17, 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: 0x00008325C7AA50D376432DFCE06E983FDF9B99AB36E705CA9AAF9737CA5E7844BB17, 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

    2B14A13B5BE67F54FEE9F081DBF1E3D29D1C0C4E92AAB6DC8DF22A070B785ED195E2060EBF6C330D750C4A771E4615E9938E73B5A4016E5127525117

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001568D78ED68AE83A90A12D03ADD07103D1599EB9CDA91BD8F084C32D06C6B4971

Previous signature

85BA3768362A73222EA608EC64F6E847B11A203CD2133683080E83F9494387551F54E3E320D78A8DFF543752715B32442EAF97932967E15FB150DF0F521E230E

Origin signature

3045022100C9A145D396A43110E24D64BBFA8A8315E8B17E454B835CA4F9E1048BFBA19140022061735742E969CBEEAB2A6EB1DC105FB9065E7B115AC57F67313E37ABE7BAF63C

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0099E78A898AD830EFC070522602F21526E8A3A9BEDBBADF109F1E050D7D0AAB65

Coordinator signature

BCB46955271ABD6112DD5BDE24707F41238C3F2FD3F3E07A8D55243905CA635A232BD99D581DC356633EE759F89616258451460789F00356963E14691E17E70C

Validator #1 public key

000162E6ADFF9FBBBC4BDBB3CD56A5A13A1E8576C3619ADC58A189F7E9A3A77FF95D

Validator #1 signature

2DE6D93824B38941C74F8B58554770BD2F560BC6988EABBE17317BC1594F432C5E86F7C4A22199B1D86E51F6D2DC315F3CC86C35E114244C3511D76726A48C06

Validator #2 public key

00011ED0B570D680BE5ECD58D2D121689DA73C46DCB38A01C6E10D06286040ADE30A

Validator #2 signature

95F83A301364A8C6DF673CE3D7EF4BFE88BC0091FFB22AA305A7D00C6C321500C0D79A5FBDC50178AE4F10C0038BA8226F4A52A03A892691C97A0008EE3B890D