# RaffleTix

RaffleTix is a smart contract used to manage raffle tickets which are minted as NFTs (ERC-1155). It also includes administrative functionalities, like managing raffle ticket claim by users, observing whale activities, and handling multi-signature locks for transfers.

### Table of Contents

1. [Public Functions](#public-functions)
2. [Multi-Sig Functions](#multi-sig-functions)

***

## <mark style="color:purple;">Public Functions</mark>

### mintTix

The `mintTix` function allows a user to mint themselves a new Raffle Tix. It only allows for up to 10 Raffle Tix to be minted at a time, to prevent spamming.

**Parameters**

| Name     | Type    | Description                                     |
| -------- | ------- | ----------------------------------------------- |
| quantity | uint256 | The amount of Raffle Tix a user wishes to mint. |

```javascript
const ethers = require('ethers');
const provider = new ethers.providers.JsonRpcProvider('<rpc-url>');
const signer = new ethers.Wallet('<private-key>', provider);
const contract = new ethers.Contract('<contract-address>', abi, signer);

let quantity = 5;

async function mintRaffleTix() {
    let tx = await contract.mintTix(quantity, { value: ethers.utils.parseEther((costToMint * quantity).toString()) });
    console.log(tx.hash);
}
mintRaffleTix();
```

***

### claimTix

The `claimTix` function allows a user to claim their awarded Raffle Tix. This function can be called only if a user has Raffle Tix to claim.

```javascript
async function claimRaffleTix() {
    let tx = await contract.claimTix();
    console.log(tx.hash);
}
claimRaffleTix();
```

***

### checkTix

The `checkTix` function checks the amount of Raffle Tix a user can claim.

**Parameters**

| Name | Type    | Description                                          |
| ---- | ------- | ---------------------------------------------------- |
| user | address | Address to check the number of claimable Raffle Tix. |

```javascript
let userAddress = '0x1234...';

async function checkRaffleTix() {
    let claimableTix = await contract.checkTix(userAddress);
    console.log('Claimable Raffle Tix: ', claimableTix.toString());
}
checkRaffleTix();
```

***

### getWhaleSizes

The `getWhaleSizes` function returns a list of token amounts owned by addresses.

```javascript
async function getWhaleSize() {
    let whaleSizes = await contract.getWhaleSizes();
    console.log('Whale Sizes: ', whaleSizes);
}
getWhaleSize();
```

***

### getWhales

The `getWhales` function returns a list of addresses owning a certain amount of tokens.

**Parameters**

| Name  | Type    | Description                                     |
| ----- | ------- | ----------------------------------------------- |
| level | uint256 | The amount of tokens owned by a single address. |

```javascript
let tokenLevel = 10;

async function getWhaleAddresses() {
    let whaleAddresses = await contract.getWhales(tokenLevel);
    console.log('Whale Addresses: ', whaleAddresses);
}
getWhaleAddresses();
```

***

### tokenURI

The `tokenURI` function returns the token metadata URI for a given token ID.

**Parameters**

| Name      | Type    | Description          |
| --------- | ------- | -------------------- |
| \_tokenID | uint256 | The unique token ID. |

```javascript
let tokenID = 1;

async function getTokenURI() {
    let uri = await contract.tokenURI(tokenID);
    console.log('Token URI: ', uri);
}
getTokenURI();
```

## <mark style="color:purple;">Multi-Sig Functions</mark>

### addMultiSigLock

The `addMultiSigLock` function is used to add a MultiSig address for locking token transfers.

**Parameters**

| Name            | Type    | Description                                           |
| --------------- | ------- | ----------------------------------------------------- |
| tokenID         | uint256 | The token ID to lock with the multi-sig address.      |
| multiSigAddress | address | The wallet address to be used to lock the token with. |

```javascript
let tokenID = 1;
let multiSigAddress = '0x1234...';

async function addLock() {
    let tx = await contract.addMultiSigLock(tokenID, multiSigAddress);
    console.log(tx.hash);
}
addLock();
```

***

### activateMultiSigLock

The `activateMultiSigLock` function activates the MultiSig lock added to a token.

**Parameters**

| Name    | Type    | Description                                      |
| ------- | ------- | ------------------------------------------------ |
| tokenID | uint256 | The token ID to lock with the multi-sig address. |

```javascript
let tokenID = 1;

async function activateLock() {
    let tx = await contract.activateMultiSigLock(tokenID);
    console.log(tx.hash);
}
activateLock();
```

***

### removeMultiSigLock

The `removeMultiSigLock` function removes a MultiSig lock from a token.

**Parameters**

| Name    | Type    | Description                                        |
| ------- | ------- | -------------------------------------------------- |
| tokenID | uint256 | The token ID to unlock with the multi-sig address. |

```javascript
let tokenID = 1;

async function removeLock() {
    let tx = await contract.removeMultiSigLock(tokenID);
    console.log(tx.hash);
}
removeLock();
```

***

### getMultiSigAddress

The `getMultiSigAddress` function returns the MultiSig address associated with a token.

**Parameters**

| Name    | Type    | Description                                       |
| ------- | ------- | ------------------------------------------------- |
| tokenID | uint256 | The token ID to return the multi-sig address for. |

```javascript
let tokenID = 1;

async function getMultiSigAddr() {
    let address = await contract.getMultiSigAddress(tokenID);
    console.log('MultiSig Address: ', address);
}
getMultiSigAddr();
```

***

### isMultiSigLocked

The `isMultiSigLocked` function checks if a token is locked.

**Parameters**

| Name    | Type    | Description                                   |
| ------- | ------- | --------------------------------------------- |
| tokenID | uint256 | The token ID to check for the multi-sig lock. |

```javascript
let tokenID = 1;

async function checkLock() {
    let lockStatus = await contract.isMultiSigLocked(tokenID);
    console.log('Is Locked: ', lockStatus[0]);
    console.log('Is Address Added: ', lockStatus[1]);
}
checkLock();
```

***


---

# 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.kuthulu.xyz/contracts/raffletix.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.
