Type
CONTRACT
Validation date
2023-12-01 04:48:50 UTC
Fee
0.20305068 UCO

Code (834 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: 0x0000F25C3DF408399FD5CC26D5A53C4081F6D6600B04B5EF4E41836D384F8B84C772, amount: 33.96112237
  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: 0x0000F25C3DF408399FD5CC26D5A53C4081F6D6600B04B5EF4E41836D384F8B84C772, amount: 33.96112237
  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: 33.85923901
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.10188336

    Contract.set_code next_code
  end

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

    FD96BF73A1D2B7DDF940C8DE2AF99842534D9CE22434B9B44D99BF3218A6C7D52A8E8B65979C772A518C9D2BCCC6D7B9882A27CD3815AB63A84FE911

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001AB205033AED93397E269E5EC954F9D4BAD824F62E862CAA97F473EDCB7EE9CBA

Previous signature

F5642FC640DA162E595EF66BB12BF216C08A62FD1E1086CBC568CC942EE12CDC0A0E7F861F411CC92FA8A35326B457C51D1E8EF9499DD47A4909AB88EB3C000B

Origin signature

3045022100DA35088AE0AD953A524E693E96F6DB360ADD3D437C7D30BDBEA21007BB79B32C02206A27272A4C2E8718F402A13F65B2265344A7F0E3837298FA29336DC161618EE2

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

002B550054A4C90EAD33A443F1956F5376A65F18E0B2171B1FC3394051650ABFEA

Coordinator signature

E2855339705C7AEDACCAD0537FFB5A438C10D348CA89795D5B6613215D51481E3D3917F7C0DD50EC8588559DDAE93BC371227F47B12DEAB46CF16315BEFE8304

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

69E7474698B0FEBE5E6B986254F2C8A7406174FB31D5152D7EFC54B992EE0519B74BB02AFB48EDFDA42BBA4F71440553BF5D54C7F3A17709914AAD1410D4520B

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

8CC5B1E48933EF7F94044C39BF87D98ABD3190053935862F66B8D1FD23AB9F21D2F4DA4806875A159341961E9579492C91FED37C066B1AFAD57DD598B663A704