Type
CONTRACT
Validation date
2023-12-05 20:13:19 UTC
Fee
0.21244293 UCO

Code (819 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: 0x000069DE327AB026CB14829D47EFC5C765183C23A6488DBFBF5B19FCF7E40175F2E9, 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: 0x000069DE327AB026CB14829D47EFC5C765183C23A6488DBFBF5B19FCF7E40175F2E9, 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

    CDA7ED392C8B82ACB55B183456B9719A23E5ABF3906C1DE374EA3EEA7A01110CCB30C8267C72772596ADACF093D82FFD301CAF18F0A8E6CDE5B1FC88

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001206138454B73B73F5D5FB6BDEAEFCA6A0B71B582A923019988AC2CD69F8FBA0C

Previous signature

C2E3958CF0BDEB4B2FE81BA1FCF41480A6ACDBF146D26BAF1709C754CDE765BEED8A1E00DA2F0331EDD077E747F89B49597C3F066D6C0480C5F619544DB27C09

Origin signature

3045022100F6725EA93DF73B232B1B02C05FC6930D6A250A556B40C9ADBECDBEC2A1B6E80802206352BAC9D6FDA1D7756B6891E14342136A638BE48B6EEBE8C6F1DA08E77407B5

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0050759CED25886663B1614B2A4EE68AC6C0A54F8AB3B39120CCC927FC8FFC71EC

Coordinator signature

3E4FACB932717CEED1082D0A55C3C4DE3231F1C74C0AD33558E6841ED66116A5D8D3E4D7F2EE7F57C003F51EAF62BAFDB5DF4E9636E6E14F17C7510010B84204

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

71F67339E39B842E627F38B0632F619C10C61909B10E75EF3912A195A397595F6C8AB5493F64C758FE7E881ADF1B6F97BADDDE260BD2BDE6E29F122558D2FC0F

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

8F15A3D30CFEF362B1E4AB9CB86449D476AF6BD3692B1502B092FA5AD7659FE881D9E386D01D0C08574D1BEAA348AF82AEB92867DD906EA846353AC393317900