> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kas.fun/llms.txt
> Use this file to discover all available pages before exploring further.

# MemeFactory

> MemeFactory contract ABI reference

## Contract Info

| Property | Value |
| - | - |
| **Address** | See [Addresses](https://docs.kas.fun/contracts/addresses.md) |
| **Network** | Kasplex (see [Addresses](https://docs.kas.fun/contracts/addresses.md) for chain details) |

## Write Functions

### createToken

Create a new token. Requires a platform signature obtained through [kas.fun](https://kas.fun).

```solidity theme={null}
function createToken(CreateTokenParams params) external payable returns (uint256 tokenId, address token)
```

**CreateTokenParams:**

| Field | Type | Description |
| - | - | - |
| `name` | string | Token name |
| `symbol` | string | Token symbol |
| `metadataUri` | string | Metadata URI |
| `creatorBuyAmount` | uint256 | Optional initial buy amount (wei) |
| `salt` | bytes32 | Salt for deterministic address |
| `nonce` | uint256 | Anti-replay nonce |
| `deadline` | uint256 | Signature expiry timestamp |
| `signature` | bytes | Platform EIP-712 signature |

**Value:** `creationFee + creatorBuyAmount`

***

### buy

Buy tokens with KAS.

```solidity theme={null}
function buy(address token, uint256 minTokensOut) external payable
```

| Parameter | Type | Description |
| - | - | - |
| `token` | address | Token to buy |
| `minTokensOut` | uint256 | Minimum tokens to receive (slippage protection) |

**Value:** Amount of KAS to spend (wei)

***

### sell

Sell tokens for KAS. Requires prior ERC-20 approval.

```solidity theme={null}
function sell(address token, uint256 tokenAmount, uint256 minKasOut) external
```

| Parameter | Type | Description |
| - | - | - |
| `token` | address | Token to sell |
| `tokenAmount` | uint256 | Amount of tokens to sell (wei) |
| `minKasOut` | uint256 | Minimum KAS to receive (slippage protection) |

***

## Read Functions

### getTokenInfo

```solidity theme={null}
function getTokenInfo(address token) external view returns (TokenInfo)
```

**Returns (TokenInfo):**

| Field | Type | Description |
| - | - | - |
| `tokenId` | uint256 | Token ID (0 if not found) |
| `creator` | address | Token creator |
| `pool` | address | Pool address |
| `tokenReserves` | uint256 | Token reserves in pool (wei) |
| `kasReserves` | uint256 | KAS reserves in pool (wei) |
| `createdAt` | uint256 | Creation timestamp |
| `fulfilled` | bool | Bonding curve threshold reached |
| `graduated` | bool | Liquidity migrated to DEX |
| `metadataUri` | string | Metadata URI |
| `paramVersion` | uint256 | Curve parameter version |

***

### getCurrentPrice

```solidity theme={null}
function getCurrentPrice(address token) external view returns (uint256)
```

Returns the current price in KAS per token (18 decimals).

***

### getBondingCurveProgress

```solidity theme={null}
function getBondingCurveProgress(address token) external view returns (uint256)
```

Returns progress from `0` to `10000` (representing 0.00% to 100.00%).

***

### getTokenParamVersion

```solidity theme={null}
function getTokenParamVersion(address token) external view returns (ParamVersion)
```

**Returns (ParamVersion):**

| Field | Type | Description |
| - | - | - |
| `graduationThreshold` | uint256 | KAS amount needed to graduate (wei) |
| `virtualToken` | uint256 | Virtual token reserve for curve |
| `virtualKas` | uint256 | Virtual KAS reserve for curve |
| `sqrtPriceX96Token0` | uint160 | Uniswap V3 sqrt price (token0) |
| `sqrtPriceX96Token1` | uint160 | Uniswap V3 sqrt price (token1) |
| `active` | bool | Whether this param version is active |

***

### computeTokenAddress

```solidity theme={null}
function computeTokenAddress(bytes32 salt, address creator) external view returns (address)
```

Predict the token contract address before creation.

***

### bondingCurve

```solidity theme={null}
function bondingCurve() external view returns (address)
```

Returns the BondingCurve contract address.

***

### creationFee

```solidity theme={null}
function creationFee() external view returns (uint256)
```

Returns the token creation fee in KAS (wei).

***

### authorizedSigner

```solidity theme={null}
function authorizedSigner() external view returns (address)
```

Returns the platform's authorized signer address.

***

## Events

### Created

```solidity theme={null}
event Created(
    address indexed token,
    address indexed creator,
    uint256 indexed tokenId,
    address pool,
    string name,
    string symbol
)
```

### Buy

```solidity theme={null}
event Buy(
    address indexed token,
    address indexed buyer,
    uint256 kasAmount,
    uint256 tokenAmount,
    uint256 fee
)
```

### Sell

```solidity theme={null}
event Sell(
    address indexed token,
    address indexed seller,
    uint256 tokenAmount,
    uint256 kasAmount,
    uint256 fee
)
```

## Full ABI (JSON)

> [accordion] MemeFactory ABI JSON
>
> ```json theme={null}
> [
>   {
>     "inputs": [{"components": [{"internalType": "string", "name": "name", "type": "string"}, {"internalType": "string", "name": "symbol", "type": "string"}, {"internalType": "string", "name": "metadataUri", "type": "string"}, {"internalType": "uint256", "name": "creatorBuyAmount", "type": "uint256"}, {"internalType": "bytes32", "name": "salt", "type": "bytes32"}, {"internalType": "uint256", "name": "nonce", "type": "uint256"}, {"internalType": "uint256", "name": "deadline", "type": "uint256"}, {"internalType": "bytes", "name": "signature", "type": "bytes"}], "internalType": "struct IMemeFactory.CreateTokenParams", "name": "params", "type": "tuple"}],
>     "name": "createToken",
>     "outputs": [{"internalType": "uint256", "name": "tokenId", "type": "uint256"}, {"internalType": "address", "name": "token", "type": "address"}],
>     "stateMutability": "payable",
>     "type": "function"
>   },
>   {
>     "inputs": [{"internalType": "address", "name": "token", "type": "address"}, {"internalType": "uint256", "name": "minTokensOut", "type": "uint256"}],
>     "name": "buy",
>     "outputs": [],
>     "stateMutability": "payable",
>     "type": "function"
>   },
>   {
>     "inputs": [{"internalType": "address", "name": "token", "type": "address"}, {"internalType": "uint256", "name": "tokenAmount", "type": "uint256"}, {"internalType": "uint256", "name": "minKasOut", "type": "uint256"}],
>     "name": "sell",
>     "outputs": [],
>     "stateMutability": "nonpayable",
>     "type": "function"
>   },
>   {
>     "inputs": [{"internalType": "address", "name": "token", "type": "address"}],
>     "name": "getTokenInfo",
>     "outputs": [{"components": [{"internalType": "uint256", "name": "tokenId", "type": "uint256"}, {"internalType": "address", "name": "creator", "type": "address"}, {"internalType": "address", "name": "pool", "type": "address"}, {"internalType": "uint256", "name": "tokenReserves", "type": "uint256"}, {"internalType": "uint256", "name": "kasReserves", "type": "uint256"}, {"internalType": "uint256", "name": "createdAt", "type": "uint256"}, {"internalType": "bool", "name": "fulfilled", "type": "bool"}, {"internalType": "bool", "name": "graduated", "type": "bool"}, {"internalType": "string", "name": "metadataUri", "type": "string"}, {"internalType": "uint256", "name": "paramVersion", "type": "uint256"}], "internalType": "struct IMemeFactory.TokenInfo", "name": "", "type": "tuple"}],
>     "stateMutability": "view",
>     "type": "function"
>   },
>   {
>     "inputs": [{"internalType": "address", "name": "token", "type": "address"}],
>     "name": "getCurrentPrice",
>     "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}],
>     "stateMutability": "view",
>     "type": "function"
>   },
>   {
>     "inputs": [{"internalType": "address", "name": "token", "type": "address"}],
>     "name": "getBondingCurveProgress",
>     "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}],
>     "stateMutability": "view",
>     "type": "function"
>   },
>   {
>     "inputs": [{"internalType": "address", "name": "token", "type": "address"}],
>     "name": "getTokenParamVersion",
>     "outputs": [{"components": [{"internalType": "uint256", "name": "graduationThreshold", "type": "uint256"}, {"internalType": "uint256", "name": "virtualToken", "type": "uint256"}, {"internalType": "uint256", "name": "virtualKas", "type": "uint256"}, {"internalType": "uint160", "name": "sqrtPriceX96Token0", "type": "uint160"}, {"internalType": "uint160", "name": "sqrtPriceX96Token1", "type": "uint160"}, {"internalType": "bool", "name": "active", "type": "bool"}], "internalType": "struct IMemeFactory.ParamVersion", "name": "", "type": "tuple"}],
>     "stateMutability": "view",
>     "type": "function"
>   },
>   {
>     "inputs": [{"internalType": "bytes32", "name": "salt", "type": "bytes32"}, {"internalType": "address", "name": "creator", "type": "address"}],
>     "name": "computeTokenAddress",
>     "outputs": [{"internalType": "address", "name": "", "type": "address"}],
>     "stateMutability": "view",
>     "type": "function"
>   },
>   {
>     "inputs": [],
>     "name": "bondingCurve",
>     "outputs": [{"internalType": "address", "name": "", "type": "address"}],
>     "stateMutability": "view",
>     "type": "function"
>   },
>   {
>     "inputs": [],
>     "name": "creationFee",
>     "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}],
>     "stateMutability": "view",
>     "type": "function"
>   },
>   {
>     "inputs": [],
>     "name": "authorizedSigner",
>     "outputs": [{"internalType": "address", "name": "", "type": "address"}],
>     "stateMutability": "view",
>     "type": "function"
>   },
>   {
>     "anonymous": false,
>     "inputs": [{"indexed": true, "internalType": "address", "name": "token", "type": "address"}, {"indexed": true, "internalType": "address", "name": "creator", "type": "address"}, {"indexed": true, "internalType": "uint256", "name": "tokenId", "type": "uint256"}, {"indexed": false, "internalType": "address", "name": "pool", "type": "address"}, {"indexed": false, "internalType": "string", "name": "name", "type": "string"}, {"indexed": false, "internalType": "string", "name": "symbol", "type": "string"}],
>     "name": "Created",
>     "type": "event"
>   },
>   {
>     "anonymous": false,
>     "inputs": [{"indexed": true, "internalType": "address", "name": "token", "type": "address"}, {"indexed": true, "internalType": "address", "name": "buyer", "type": "address"}, {"indexed": false, "internalType": "uint256", "name": "kasAmount", "type": "uint256"}, {"indexed": false, "internalType": "uint256", "name": "tokenAmount", "type": "uint256"}, {"indexed": false, "internalType": "uint256", "name": "fee", "type": "uint256"}],
>     "name": "Buy",
>     "type": "event"
>   },
>   {
>     "anonymous": false,
>     "inputs": [{"indexed": true, "internalType": "address", "name": "token", "type": "address"}, {"indexed": true, "internalType": "address", "name": "seller", "type": "address"}, {"indexed": false, "internalType": "uint256", "name": "tokenAmount", "type": "uint256"}, {"indexed": false, "internalType": "uint256", "name": "kasAmount", "type": "uint256"}, {"indexed": false, "internalType": "uint256", "name": "fee", "type": "uint256"}],
>     "name": "Sell",
>     "type": "event"
>   }
> ]
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.