Type
CONTRACT
Validation date
2023-11-13 18:59:12 UTC
Fee
0.17320539 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: 0x0000A487AD42A5AA666E2021057C89AB92C97513B31EE65DCA76132BEDE148B12843, amount: 50
  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: 0x0000A487AD42A5AA666E2021057C89AB92C97513B31EE65DCA76132BEDE148B12843, amount: 50
  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: 49.85
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.15

    Contract.set_code next_code
  end

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

    901CB1D43224A104E51A4659F97D24171A3E4328E76105B2A81BB152035949D742DB1BB45BCBA3396E33BD36415B30A27CFEC6E6871367E28B9788CF

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001C5819C00FD323184C574597A19D5BFEB39EBC95A65DA40ABBA21B60E5F10229F

Previous signature

445A5A195FE3227DE152316E7FAB51F60F5D0EC0BD7892C439F5F6F6E8DA690EAACDB491D4CA1D1B4AF5EDD2C14E01512A93C60EC6C36FE94D018CA2397FAD08

Origin signature

304502210093D90C10589D02C0F515C705B645513358431880C8492DF5D5AA3F6044D90BDF022063EC285C7B1FBBD6208C3C04CAE41490F87EB5C60FBF3DFF0991C536AF399093

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00609853F8484B2951598EA48CAA83C37D8274107B1A58496BF4C974009F28F87D

Coordinator signature

5471FD4B662923DE2291173F5F3FDEACF5D37C61AC30D33925230451BD9EC754ACA88E5062715B3CA6C5F94D193F8A9ABBCF1180AC5412F5082BDA9CB5AD220D

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

801B3ACBF5E39154EDBE8A2AFFC38A39B17FB44B97C868CFBC8D0F0E05C8CBF29486784E90A9ECC08918BA2E57EBEDBC14C2353AAE9B3B8A412056EA3CA6DD0A

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

2213BBF9C87616361AC8A31C8A209CEFB1A7C9825CF5B3EB5512FF9EF60EFE037A2E57178EF24827B45FC521C6EE2DDF4AB44140B5EF4A729A46319D8DB6AE0C