> For the complete documentation index, see [llms.txt](https://docs.metapass.world/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.metapass.world/quick-start/smart-contract-requests.md).

# Smart Contract Requests

## Prerequisites

For this section, you will need:

* A user's Theta Network wallet address, see the previous page on how to obtain this
* A web3 library installed, such as [ethers.js](https://www.npmjs.com/package/ethers), and connected to the Theta Mainnet RPC endpoint
* [web3-react](https://www.npmjs.com/package/web3-react)
* The smart contract address(es) of your event

## Checking ownership of a ticket

{% tabs %}
{% tab title="React TSX" %}

```tsx
import { useWeb3React } from '@web3-react/core'

const { library } = useWeb3React()

async function getTicketContractBalance(ticketAddress: string, library: any) {
  return library.getBalance(ticketAddress)
}
```

{% endtab %}
{% endtabs %}

## Stamping a ticket

This requires a smart contract interaction, and therefore will cost gas. You will need to [obtain an intstance of ticket contract](/quick-start/miscellaneous.md#getting-a-smart-contract-instance-with-ethers) first.

```tsx
import { BigNumber, ethers } from 'ethers'

const { library, account } = useWeb3React()

const ticketAddress = "..."
const ticketId = "..."
const TicketABI = "..." // you can get the ABI from the reference document

const TICKET_CONTRACT = getContract(ticketAddress, TicketABI, library, account)

const GAS_MARGIN = BigNumber.from(1000)

function calculateGasMargin(value: BigNumber, margin: BigNumber) {
  const offset = value.mul(margin).div(BigNumber.from(10000))
  return value.add(offset)
}

const handleStamp = () => {
  if (ticketAddress && ticketId !== undefined && TICKET_CONTRACT) {
    let estimate = TICKET_CONTRACT.estimateGas.stampTicket;
    let method = TICKET_CONTRACT.stampTicket;
    const ticketIdBN = BigNumber.from(ticketId)
    let args = [
      ticketIdBN
    ];
    let value = ethers.constants.Zero
    return estimate(...args, { value }).then((estimatedGasLimit: any) => {
      return method(...args, {
        value,
        gasLimit: calculateGasMargin(estimatedGasLimit, GAS_MARGIN)
      })
    }).then((tx: any) => {
      return true
    }).catch((e: Error) => {
      console.log(e.message)
      return false
    })
  }
}
```
