Skip to content

Unable to getTotalHeartBitCountByHash  #1

Closed
@Joshua-onwuzu

Description

@Joshua-onwuzu

i am trying to call the function below, in my react code to be able to get the token total supply and user token balance but i am getting the error Cannot read properties of undefined (reading 'then')
here is the error
Untitled 2

here is the function :

export const getTotalTokenInformation = async (
  hash: string,
  address: string,
) => {
  console.log("here");
  const totalSupply = await coreSDK.getTotalHeartBitCountByHash({ hash });
  console.log(totalSupply);
  const mintsByUser = await coreSDK.getHeartBitByUser({
    hash,
    address,
  });

  return { totalSupply, balance: mintsByUser };
};

here is how i am trying to use it in my react code

function App() {
  const tokenId =
    "0x854e8c653cbe480b562a6919a936eff545c2accdea26d92f3de792bd8add927a";
  const [tokenInfo, setTokenInfo] = useState<any>({});

  const loadTokenInfo = async () => {
    const res = await getTotalTokenInformation();
    setTokenInfo(res);
  };


  useEffect(() => {
    loadTokenInfo();
  }, []);
  return (
    <div>
      <h1>Total Supply: {tokenInfo?.totalSupply}</h1>
      <h1>Total Supply: {tokenInfo?.balance}</h1>
      <button onClick={() => mintToken(tokenId)}>MINT TOKEN</button>
    </div>
  );
}
```

export default App;`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions