Type
CONTRACT
Validation date
2023-10-24 14:20:14 UTC
Fee
0.3122008 UCO

Code (818 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: 0x00009E731DE71C9598A6C853EA89C736B1DAC3652AE00753651B642536AB14821F06, amount: 8
  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: 0x00009E731DE71C9598A6C853EA89C736B1DAC3652AE00753651B642536AB14821F06, amount: 8
  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: 7.976
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.024

    Contract.set_code next_code
  end

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

    83390D0A6B9E50EABD80A142B92DF0F0CC268606E8FECC23B99A47B7CB8825E13ED315EA28784E765524273C652AA5A7CD93BCEC32A996EFCD3194F2

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00012386BEA2B9F23A9DB0BF92498DB4B53F50D5934D59D1D6A32E5895FEF3374876

Previous signature

03B2D2E6BC1D5E2D0EC3EC26A5AE2AA213C5825544D28E1CCCFBE3DB4771E113E02EAC70A9FAB2C062F8A3E9CE1BC405C3B00F801A4134D8236F6214B1412601

Origin signature

30440220542DD0ACF2AA605D9A337D78C51F4A5B3EA1F6C584C3201602F2A8629DFFE3090220474FBE00C58E2BF22BE1E70C1E27F1B5A0550D2B6BBAB02D011A368B5A580B76

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00E3852153834C44F66C3802BED9D1CEDBC82AA217F34FECF112BF55F4E7F3E615

Coordinator signature

A3C7BC621463B7E2962A72A29028A0863AB6B627670B94716EF37709C6A0F3710DF8EB4E1A3569687C9B204331E9EB03271895BA8606027ABE774BCA04AE350B

Validator #1 public key

00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC

Validator #1 signature

866843024C1DCFBDB1A80824B43699096457809E3EB6848BF0ADB666ADE55FAEB5B747063A44B362C557975C3ED9AD103483E3162604B9E407282F703E567A0B

Validator #2 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #2 signature

BEFF64CF5575AAB3735598ACE431A59AFBF26BE2D1F64CABD13F4E08DC2BC08C6DF534E9ADD4146122F6C7C5A22ACB527E7D3E541ADD8354B1F9AE0073DFBC00