Skip to content
Starknet Start

useContract

Get a typed contract.

This hook is equivalent to creating a new Contract instance with the current provider and then calling typedv2 with the provided ABI.

Usage

import {  } from "@starknetfoundation/starknet-start-react";
 
const  = "0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7";
 
const  = [
  {
    : [
      {
        : "low",
        : "felt",
      },
      {
        : "high",
        : "felt",
      },
    ],
    : "Uint256",
    : "struct",
  },
  {
    : [
      {
        : "name",
        : "felt",
      },
      {
        : "symbol",
        : "felt",
      },
      {
        : "recipient",
        : "felt",
      },
    ],
    : "constructor",
    : "constructor",
  },
  {
    : [],
    : "name",
    : [
      {
        : "felt",
      },
    ],
    : "view",
    : "function",
  },
] as ;
 
const {  } = ({
  ,
  : ,
});

Data

  • Type: StarknetTypedContract

Typed contract with abi-wan-kanabi types.

Arguments

address

  • Type: 0x${string}

The contract address.

abi

  • Type: Abi

The contract abi.

provider

  • Type: ProviderInterface | null | undefined

ProviderInterface is from starknet.js. by default it will be the current one

Returns

contract

  • Type: StarknetTypedContract | undefined

Typed Contract