Type
CONTRACT
Validation date
2023-12-09 11:52:06 UTC
Fee
0.20678963 UCO

Code (820 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: 0x00007011C3312E6DD64C930A68B7B5F99AA6FC8FAC555DC1421BADB3091E3786B826, amount: 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: 0x00007011C3312E6DD64C930A68B7B5F99AA6FC8FAC555DC1421BADB3091E3786B826, amount: 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: 4.985
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.015

    Contract.set_code next_code
  end

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

    2CF5C42E22C79888A5230920F7B4042579D9D33506D388FA7B4226556213D015B29040A76AF23C76CDF9CB3D949144131FCE5293D51A2A576EBCB9E5

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00014917720621F03B7D1890546C6FBBB8F610A54E787F3583C49C243FE6D25E9208

Previous signature

83B029DBF8BDC1BF5ECC57B059DAA2EB1C1EE8ADB5D2A492C30823E41DF0A1FBDD4198A2F0BF287B347C5D6900D60A991A94769BE7F6FE39C32958598BF82705

Origin signature

3045022100EA994EF84B2D46F0F18904C3B20B699724648255BC9F462A101DE259B69715B702202C2FD96A14E153D347F124262AE2B7D3162AB9DAEBBA9317639ED5108E6A358C

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00BDF30156D66ED09B467ED5E226B5F9B96375F0B243E18C2B7EBE27D011A78A82

Coordinator signature

409DCB797E919AFB7C0BABC8B976613E1C1EEBC81CD03A5C81EA889286E3AD1D721B39FD43DB8C67F1418F9868DAD302A09F2640F2AFD8B9591501DECC050A02

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

F7CA5BF74541CEF8C7A56815B4CDC3D17E92DCD3A0F3CF1AE55C301C873CA864B1ADE690ADEE4E7079E1FBF29D7A3A3C4B13E4A2D9F4DB2446A899902D05D303

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

62C908AB85735080BA1612EBE78CE027FF8B82DB6D607087A748213FBDD8C7E973445535580B89AA41F79C71135A849A97CFF6BCA21995751070BCC9950EC80A