Type
CONTRACT
Validation date
2023-11-30 15:23:31 UTC
Fee
0.20927037 UCO

Code (821 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: 0x000058E3DF7A6465DB6002CCAF6D4E9811C7AFC3BFFB59C08DD168BC16B3643B7A31, amount: 2
  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: 0x000058E3DF7A6465DB6002CCAF6D4E9811C7AFC3BFFB59C08DD168BC16B3643B7A31, amount: 2
  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: 1.994
    Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.006

    Contract.set_code next_code
  end

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

    26CB3FF8737979E346BF18396E6ED1DCB15EF1CC1F11395A3C8C8EEBBD287AAC1AB3308803EAC9D86D6245454921CA3874115AB9D879E86EDD3AB066

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00017AE347435F242DAA6D78415FDC18A4FAF11790A4ED3E892DF8BA0C9857C53270

Previous signature

7900C70961F2201F7605F3219E5A8208D7CA90AD64061ADB8B04381D7CD1DE225B4F021D3A42E6C77EC6CD0E9FC57E485E3A7B89D3541FBE043794FC6655860C

Origin signature

3045022100E1A89078EFE202034B5A229C4FCDCFB6A42E88E21C03BBF8110C8D054F6E24B602204EEAB30463A9F4C5D14869DB71172AB43AEB5219BB0198123155F46F475933E6

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

005AFBA383478AEBB1F11331CD2B80EAD7686D0D7EBBBE8327FB6D96CEAD4078CF

Coordinator signature

5C1F91682BCF1A8DE535B795FAC4DB279AEB2E8DA7AE5B924CCF662012BBC13381E30642D868DD459F61E25BA3F8BCDFD3E8326125810B3D304E1DC871233E00

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

98E50B79AB5C01C478D0FC157D3B4CAA784007758DE488B4571DF7990DE85D120C087EEFCEDE63DD9A039AD1FCC9DC15A6229D11C0AF02E0CDF5940B0C2C7D09

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

B8A8A54B068C316ED4EF3D22E4BC579154452248D664F08874B16A8E98EF005384438B6ACD07E6165051790238822C09A3A7D57B371A07C961173A60AA975E07