Type
CONTRACT
Validation date
2023-11-19 13:08:58 UTC
Fee
0 UCO

Code (867 B)

@version 1
# Automate the refunding after the given timestamp
actions triggered_by: datetime, at: 1700406480 do
  Contract.set_type "transfer"
# Send back the token to the user address
Contract.add_uco_transfer to: 0x0000D9E7B4300CC29670CA80010FE23292BEE4AE28057328732A0FF4CF11C319D81A, amount: 250
Contract.set_code ""

end

condition triggered_by: transaction, on: refund(), as: [
  timestamp: timestamp >= 1700406480
]

actions triggered_by: transaction, on: refund() do
  Contract.set_type "transfer"
# Send back the token to the user address
Contract.add_uco_transfer to: 0x0000D9E7B4300CC29670CA80010FE23292BEE4AE28057328732A0FF4CF11C319D81A, amount: 250
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 < 1700406480,
  content: Crypto.hash(String.to_hex(secret)) == 0x1C8694005CDAFE04A7DFF4F24FD2D00E5D285AD375DE4689245699C9020E240F
]

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: 249.25
  Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.75

  Contract.set_code next_code
end

export fun get_htlc_data() do
  [
    amount: 249.25,
    end_time: 1700406480,
    secret_hash: 0x1C8694005CDAFE04A7DFF4F24FD2D00E5D285AD375DE4689245699C9020E240F,
    secret_hash_signature: [
      r: 0x12134DEAB2294DFEFBE24F20E1F31ABF9514C76675720DB0EFD6D554F7D53026,
      s: 0x0BCDD6BA77B2007E2FAEFA5862FCC6B5EA5858499C85F7BBC6C0BCB92210DA04,
      v: 28
    ]
  ]
end

Content (0 B)

State (0 B)

Movements (0)

Ownerships (1)

  • Secret shared with 1 key

    Encoded secret

    8D10EE22345CA562B61F633113C86794A28C13716C64A890BEBB8E673093E0AF4A657E0E06C4A43910091D0571B639322F2FDFE8CCAF9891B084E129

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001B9F9A823E1DF69F341FC45936B4A8F09B377638E304B49F923FF1BC85EF47697

Previous signature

544B1985A81875CDAE1BA8EBE1394F38F0813CC79F01535E41EB79201EBCF9257A4A32220AD100971235A7883C842EE0EBC14DF3F88C7918B11886C24568E405

Origin signature

3044022078A017C8F24B191C16710AB62C3DC3CA28CC38A44EA75D57765FD06D1962861902204BA1DFBA5AB14DAAD9783FCEEF2F1CCF8D2B417E793D31A1508D855342F87F3F

Proof of work

010104EB90F7BDD03D5A7FD9B61D9128D7CF24C11F3F7DA96825DA3680C2B6BCC48F1AFCE26E0A5F1A903EDAA4BC9390210A0A4F175847EC2A2BB325BB6D1CE8EC8F90

Proof of integrity

0014034EA8B736163AF0C3C7EA3344E3132E232A67F9FC2A2DDB75F9E29FFC17AA

Coordinator signature

7395D1B09150F03F4819B2BA042DBC96D4474EE23B13AC60C2E918B0EF4CE7A64040A8CFDCBC2172614AA7D9597BDFBCA6D956768304E3CC7617155A2660C707

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

3ECBF95AF469F6A71D07BC4B1B02CC4AAF600943F651DE835DB19C160A97EC570F186A88D8CD76F55E35447B2F2379365A940298E35D9857A1E033B42337A80C

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

8DE1255600EBA75BFE2B06E16138D3D873719CA0F44C1698FEE51EEB7274AA373426EDEE0DFCE34697D064B722BA7788DB3CEF90299701AEF07CD76ABA07C105