Type
CONTRACT
Validation date
2023-10-19 20:57:19 UTC
Fee
0.24970403 UCO

Code (818 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: 0x00007D1163F2AEA7B80362450AB96D837F5A698980E2FCC0ABE1CDB01D9B7F0D2273, amount: 0.5
  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: 0x00007D1163F2AEA7B80362450AB96D837F5A698980E2FCC0ABE1CDB01D9B7F0D2273, amount: 0.5
  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: 0.4985
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.0015

    Contract.set_code next_code
  end

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

    2E9C64E710E6BF5E6EDF6179E5FA72A814667CC0B41B5525733EC994FFE4C7417D5EDAB17E8781FE4350A600411D28147BEA56F950B418147C0B9388

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001875D6882DA8B95FED3CE4B38B954BA662A1E0149CFD00922AD1257C5F289F8C3

Previous signature

E8EB461E7D422B696FB29862A9BD32B62331C95E5D59468E9CA839B6A0A68D6834CB9D0B9549B82BE9A84AB4CE4715562C03F85BB3C9766592CA32770D3A7209

Origin signature

304402203430ED89F16D8A0FC269679F9F0C0082CAF43FA51FC0D496C2E36DED8712FBA50220079C08D6A884F4A4AADECC12CE27F6B54261B340EC9895E4ECF67123C3E52FD8

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00A7D665917D9F169295E98B4D2CE21E02C0A2E49C2EAC0B82FF81C2C039CD8ACA

Coordinator signature

9CEC289D294DD7F5C2F0E9AB3C78CFB2BF61F564C2314695D57BED61E60CB1577DD0DAA9D2C37B508BDC6C70AC1C805C78AA67FFBD4E1541FF2D895D266AE409

Validator #1 public key

00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC

Validator #1 signature

4353D807F925F7D3D3F148D67497AE9C63BA47A872CA57580D54859EADDE125141514ECEA24BE34595D20C59F49EA35AB9567E69AC8AC40BA5F0474D0E53580A

Validator #2 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #2 signature

E44306C46AE5C690B7252B778A8707448E11C6C072332520DE72A357D127E57D4719B3309C81EDE980D2CB445F139B885B8C8FBDFF88E684FFCE93550E996C03