Type
CONTRACT
Validation date
2025-04-02 12:42:28 UTC
Fee
0.00000001 UCO

Code (936 B)

@version 1

condition triggered_by: transaction, on: set_secret_hash(_secret_hash, _secret_hash_signature, _end_time, _evm_pool), 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) == 0x00007038773E1FA4698176FC432F65EAF9B76758D1367AFCA5793CA653837135CA1E
  )
]

actions triggered_by: transaction, on: set_secret_hash(secret_hash, secret_hash_signature, end_time, evm_pool) do
  Contract.set_code """
  @version 1

  condition triggered_by: transaction, on: refund(secret, secret_signature), as: [
    previous_public_key: (
      previous_address = Chain.get_previous_address()
      Chain.get_genesis_address(previous_address) == 0x00007038773E1FA4698176FC432F65EAF9B76758D1367AFCA5793CA653837135CA1E
    ),
    timestamp: timestamp >= #{end_time}
  ]

  actions triggered_by: transaction, on: refund(secret, secret_signature) do
    Contract.set_type "transfer"
    # Send back the token to the user address
    Contract.add_token_transfer to: 0x00009D97E06EA7F60C3259CAF5A614ED134EE54159F6197B23642D8F81814442B70D, amount: 7.372e-5, token_address: 0x00002CEC79D588D5CDD24331968BEF0A9CFE8B1B03B8AEFC4454726DEF79AA10C125

    Contract.set_code \"""
    @version 1

    export fun info() do
      [
        evm_pool: #{evm_pool},
        ae_pool: 0x00007038773E1FA4698176FC432F65EAF9B76758D1367AFCA5793CA653837135CA1E,
        status: 2 # REFUNDED
      ]
    end

    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
    \"""
  end

  condition triggered_by: transaction, on: reveal_secret(secret, secret_signature, _evm_contract), 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) == 0x00007038773E1FA4698176FC432F65EAF9B76758D1367AFCA5793CA653837135CA1E
    ),
    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, evm_contract) do
    Contract.set_type "transfer"
        Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 7.372e-5, token_address: 0x00002CEC79D588D5CDD24331968BEF0A9CFE8B1B03B8AEFC4454726DEF79AA10C125
    # Transfer fee is less than the minimum decimals


    Contract.set_code \"""
    @version 1

    export fun info() do
      [
        evm_contract: \#{evm_contract},
        evm_pool: #{evm_pool},
        ae_pool: 0x00007038773E1FA4698176FC432F65EAF9B76758D1367AFCA5793CA653837135CA1E,
        status: 1 # WITHDRAWN
      ]
    end

    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
    \"""
  end

  export fun info() do
    [
      evm_pool: #{evm_pool},
      ae_pool: 0x00007038773E1FA4698176FC432F65EAF9B76758D1367AFCA5793CA653837135CA1E,
      status: 0 # PENDING
    ]
  end

  export fun get_htlc_data() do
    [
      amount: 7.372e-5,
      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
  """
end

export fun info() do
  [
    ae_pool: 0x00007038773E1FA4698176FC432F65EAF9B76758D1367AFCA5793CA653837135CA1E,
    status: 0 # PENDING
  ]
end

Content (0 B)

State (0 B)

Movements (0)

Ownerships (1)

  • Secret shared with 1 key

Contract recipients (0)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures