Type
CONTRACT
Validation date
2023-12-28 20:29:50 UTC
Fee
0.20308826 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: 0x0000AAE847768F278B0D458240DC4E5205C2CB307B81D81865338F2C6B831F6006B1, 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: 0x0000AAE847768F278B0D458240DC4E5205C2CB307B81D81865338F2C6B831F6006B1, 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

    1B8D87B37F1359577B05C723C4459A457300DFE0C85A7899C331833C2899A0568A60B13EEA82BB64D8CF94190AB2C6C96CDE1613E879E1BB720593CB

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001E61494F7234F56E84B0D8BEB48D74D3426D7F67A1F9C2EB805208724085D332A

Previous signature

B4403DA4EC7528DA58733A8536797F6B9E2F55B19AD27CD36D7202317388DB9B002A8A18C2586FEC935B2F0AB2E26A71842655D01B2B12E3C6CF0D7FB8369207

Origin signature

3044022023F66E228E360AB9597620E13FCD08E0D479A27CD92C084239693AF344F1229602207E89A566AFA0199E79BE0C5422E0AF79210C7574F61443990007480C081CF991

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00F09925F87CB631D3382D2B42BC150BBC12FC77C5341AD1D61BD3EE202DF2E636

Coordinator signature

D8BEFA944CBB6A05895A85B10D477948C6BA9B296B805DE27869C0BE8CFB8A396EEC4C40A08345AF36C69AC3313D9932FB2F044318F255D8955ED5E4A3675B01

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

0D5A33616CCE3A060D713D402F1A62CB1C0B0F3E68F6BE67F2DB65C4D6A9B3BFCF295D26B6A23DE2E94C78014E403E8451026C5757B5B9DFF5E59D883A66BC06

Validator #2 public key

00010F2A0E4C424582A94BD90E05FE6931628F91988ABBE387D365994F1F3FCF5A12

Validator #2 signature

BA21440709E13D010533C57C9BEE78318667B93623BBF67D0F52CB6A8C52B4BF4003AA5CE504398ED9DB61A976BDC2040BD15F1659F7AB9B7E8DCCAEBDA90E08