> For the complete documentation index, see [llms.txt](https://developers.alpha.wtf/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.alpha.wtf/keys-contract-interaction.md).

# Keys Contract Interaction

Call the Keys contract for price calculation, buying, selling, and staking.

### Contract API

```
export const TOKEN_ABI = [
  {
    "inputs": [
      {
        "internalType": "uint256",
        "name": "amountX18",
        "type": "uint256"
      }
    ],
    "name": "getBuyPriceAfterFeeV2",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  }, {
    "inputs": [
      {
        "internalType": "address",
        "name": "account",
        "type": "address"
      }
    ],
    "name": "balanceOf",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint256",
        "name": "amountX18",
        "type": "uint256"
      }
    ],
    "name": "getSellPriceAfterFeeV2",
    "outputs": [
      {
        "internalType": "uint256",
        "name": "",
        "type": "uint256"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint256",
        "name": "amountX18",
        "type": "uint256"
      }
    ],
    "name": "sellKeysV2",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [],
    "name": "symbol",
    "outputs": [
      {
        "internalType": "string",
        "name": "",
        "type": "string"
      }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "token",
        "type": "address"
      },
      {
        "internalType": "uint256",
        "name": "amountX18",
        "type": "uint256"
      },
      {
        "internalType": "uint256",
        "name": "buyPriceAfterFeeMax",
        "type": "uint256"
      }
    ],
    "name": "buyKeysV2ByToken",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
 {
    "inputs": [
      {
        "internalType": "bytes[]",
        "name": "data",
        "type": "bytes[]"
      }
    ],
    "name": "multicall",
    "outputs": [
      {
        "internalType": "bytes[]",
        "name": "results",
        "type": "bytes[]"
      }
    ],
    "stateMutability": "payable",
    "type": "function"
  },
   {
    "inputs": [
      {
        "internalType": "uint24",
        "name": "ratio",
        "type": "uint24"
      },
      {
        "internalType": "uint256",
        "name": "duration",
        "type": "uint256"
      },
      {
        "internalType": "bool",
        "name": "locked",
        "type": "bool"
      }
    ],
    "name": "stakingClose",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "uint24",
        "name": "ratio",
        "type": "uint24"
      },
      {
        "internalType": "uint256",
        "name": "duration",
        "type": "uint256"
      },
      {
        "internalType": "bool",
        "name": "locked",
        "type": "bool"
      },
      {
        "internalType": "uint256",
        "name": "lockAmount",
        "type": "uint256"
      },
      {
        "internalType": "uint256",
        "name": "buyPriceAfterFeeMax",
        "type": "uint256"
      }
    ],
    "name": "stakingOpen",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "token",
        "type": "address"
      },
      {
        "internalType": "bytes32",
        "name": "orderId",
        "type": "bytes32"
      }
    ],
    "name": "stakingOrderClose",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      {
        "internalType": "address",
        "name": "token",
        "type": "address"
      },
      {
        "internalType": "bytes32",
        "name": "orderId",
        "type": "bytes32"
      },
      {
        "internalType": "uint24",
        "name": "ratio",
        "type": "uint24"
      },
      {
        "internalType": "uint256",
        "name": "duration",
        "type": "uint256"
      },
      {
        "internalType": "bool",
        "name": "locked",
        "type": "bool"
      },
      {
        "internalType": "uint256",
        "name": "amount",
        "type": "uint256"
      }
    ],
    "name": "stakingOrderCreate",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
    ]
```
