Type
CONTRACT
Validation date
2023-10-18 21:26:23 UTC
Fee
0.25101144 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: 0x00008A140026B9CA26355E22AC341F39F16EAC5A2B7B82BB468572937E04F2A65448, amount: 0.01
  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: 0x00008A140026B9CA26355E22AC341F39F16EAC5A2B7B82BB468572937E04F2A65448, amount: 0.01
  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.00997
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 3.0e-5

    Contract.set_code next_code
  end

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

    F2E4847C4794472498F674E5A88AE74D732247F3E893C3BC6AE03DE2FBB003500F8F3EA9C8C4F9FC0D8CD83695DFF9912649B62C344475CB4E9BA4EB

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00018D3E543DF47FD2859E6463E109CE1361F5AB9ED88FCC0B4C9DEB204FE475B9DE

Previous signature

3184FC83CFAFD16D792DF7F71F77BD7E218510436F1B9CCB9C3C4FFE926DDFE87174D20283F9FDE8201D7D6CA9CE9393CC92C5CF1055830102FC5A5B6397EE01

Origin signature

3045022100CBE88A91E47E2CC251E88C8018C6C9F939C37B88884B79703E01A6AD397AA70B02202252DC68050B6E65769669348D84BA6F37827BD2607D6929FAB8E76B8F634056

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0066A63E6DB12E1F412C3C4EBB7B6D82B328A64FED950D730A86392120F2CA4590

Coordinator signature

15DE599956C297E7A5AE75FFE5FF3DE479EBDF41343B22E42AA0F29443DF8D3924708898487B8222A55CA50DC8FF91F6973902798C909C99F85AA38D2A1F9801

Validator #1 public key

00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC

Validator #1 signature

0B9C7FBE6B3DE86F725F052898430A50CA6172330BB4B202E530C506637B6164C629036C79DF109604B6902C479E0F302A78706E9BCDEC17E7401DA07514510A

Validator #2 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #2 signature

9A1FB998E3498A7C905F2925436D95D4AB39EE9781289273CB9F80B2FE61EE2706BA3E8C0FA847CC214FFB9CB13076614BAB61F645684DC97C6A45229CBC8A0C