# PalLoanToken

**PalLoanTokens** are **ERC721** tokens to represent the ownership of a **PalLoan**. Each token has an id, is linked to a **PalLoan** (by the address), and to a **Borrow** in the **PalPool** that created the **PalLoan**.

**PalPools** only can mint and burn **PalLoanToken**.

When a **PalLoanToken** is burned, a **burnedPalLoanToken** is minted with the same token Id, representing closed (or killed) **Borrows**/**PalLoans**.

**PalLoanTokens** represent active **PalLoans** and **burnedPalLoanTokens** represent closed **PalLoans**.

## Methods :

### Events :&#x20;

**NewLoanToken**

`event NewLoanToken(address palPool, address indexed owner, address indexed palLoan, uint256 indexed tokenId);`&#x20;

**BurnLoanToken**

`event BurnLoanToken(address palPool, address indexed owner, address indexed palLoan, uint256 indexed tokenId);`

**Transfer**

`event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);`

**Approval**

`event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);`

**ApprovalForAll**

`event ApprovalForAll(address indexed owner, address indexed operator, bool approved);`\ <br>

### Read-only methods :

**name**

`function name() public view returns(string);`

Name of the token (PalLoan Token)

**symbol**

`function symbol() public view returns(string);`

Symbol of the token (PLT)

**controller**

`function controller() public view returns(address);`

Address of the Paladin Controller

**burnedToken**

`function burnedToken() public view returns(address);`

Address of the BurnedPalLoanToken Contract

**balanceOf**

`function balanceOf(address owner) external view returns (uint256 balance);`

Amount of tokens owned

**ownerOf**

`function ownerOf(uint256 tokenId) external view returns (address owner);`

Owner of the token (by tokenId)

**allOwnerOf**

`function allOwnerOf(uint256 tokenId) external view returns(address);`

Owner of the token, active or burned

**loanOf**

`function loanOf(uint256 tokenId) external view returns(address);`

Address of the PalLoan linked to the given token

**poolOf**

`function poolOf(uint256 tokenId) external view returns(address);`

Address of the PalPool that minted the token

**loansOf**

`function loansOf(address owner) external view returns(address[] memory);`

List of active PalLoans owned by the user

**tokensOf**

`function tokensOf(address owner) external view returns(uint256[] memory);`

List of tokens owned by the user (list of token Ids)

**loansOfForPool**

`function loansOfForPool(address owner, address palPool) external view returns(address[] memory);`

List of active PalLoans owned by the user for the given PalPool

**allTokensOf**

`function allTokensOf(address owner) external view returns(uint256[] memory);`

List of all the tokens owned by the user, active or burned (burned tokens are fetched from the BurnedPalLoanToken contract)

**allLoansOf**

`function allLoansOf(address owner) external view returns(address[] memory);`

List of all the active and closed PalLoans owned by the user

**allLoansOfForPool**

`function allLoansOfForPool(address owner, address palPool) external view returns(address[] memory);`

List of all the active and closed PalLoans owned by the user, for a given PalPool

**isBurned**

`function isBurned(uint256 tokenId) external view returns(bool);`

Returns 'true' if the token was burned

**getApproved**

`function getApproved(uint256 tokenId) external view returns (address operator);`

Address approved to spend the given token

**isApprovedForAll**

`function isApprovedForAll(address owner, address operator) external view returns (bool);`

Returns 'true' if the operator is approved for the given owner

### **State-changing methods :**&#x20;

**approve**

`function approve(address to, uint256 tokenId) external;`

Approve the given address to spend the token

***Parameters :***&#x20;

| name    | type    | desc                       |
| ------- | ------- | -------------------------- |
| to      | address | address to approve         |
| tokenId | uint256 | Id of the token to approve |

**setApprovalForAll**

`function setApprovalForAll(address operator, bool _approved) external;`

Approve or remove the given address as operator for the caller. Operators have approval on all of owner's tokens

***Parameters :***&#x20;

| name       | type    | desc                                         |
| ---------- | ------- | -------------------------------------------- |
| operator   | address | address of the operator                      |
| \_approved | bool    | 'true' to set as operator, 'false' to remove |

**transferFrom**

`function transferFrom(address from, address to, uint256 tokenId) external;`

Transfer the token from the owner to the given address (if approved or owner)

***Parameters :***&#x20;

| name    | type    | desc                        |
| ------- | ------- | --------------------------- |
| from    | address | owner of the token          |
| to      | address | recipient                   |
| tokenId | uint256 | Id of the token to transfer |

**safeTransferFrom**

`function safeTransferFrom(address from, address to, uint256 tokenId) external;`

Transfer the token from the owner to the given address (if approved or owner)

***Parameters :***&#x20;

| name    | type    | desc                        |
| ------- | ------- | --------------------------- |
| from    | address | owner of the token          |
| to      | address | recipient                   |
| tokenId | uint256 | Id of the token to transfer |

## **BurnedPalLoanToken**

Token minted when a **PalLoanToken** is burned. **BurnedPalLoanToken** are not transferable and are linked to the same **PalLoan** (and **Borrow**) that burned the **PalLoanToken**.

The **PalLoanToken** contract is the only one allowed to mint **BurnedPalLoanToken.**

## Methods :

### Events :&#x20;

**NewBurnedLoanToken**

`event NewBurnedLoanToken(address indexed to, uint256 indexed tokenId);`\ <br>

### Read-only methods :

**name**

`function name() public view returns(string);`

Name of the token (burnedPalLoan Token)

**symbol**

`function symbol() public view returns(string);`

Symbol of the token (bPLT)

**minter**

`function minter() public view returns(address);`

Address of the Minter (the PalLoanToken contract)

**totalSupply**

`function totalSupply() public view returns(uint256);`

Total supply of the token

**balanceOf**

`function balanceOf(address owner) external view returns (uint256 balance);`

Amount of tokens owned

**ownerOf**

`function ownerOf(uint256 tokenId) external view returns (address owner);`

Owner of the token (by tokenId)

**tokensOf**

`function tokensOf(address owner) external view returns(uint256[] memory);`

List of tokens owned by the user (list of token Ids)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.paladin.vote/paladin-lending/technical-docs/palloantoken.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
