Untitled

user_4748127 avatar
user_4748127
Plain Text
04/21/2023 1:06 AM
514 B
20
Indexable
Never

const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
const contractInstance = new ethers.Contract(contractAddress, abi, signer);

async function getPrice() {
  const totalTokensSupply = await contractInstance.totalTokensSupply();

  const totalEthInContract = await provider.getBalance(contractAddress);

  const price = await contractInstance.getPrice(totalEthInContract, totalTokensSupply);

  console.log("Current price:", price.toString());
}

getPrice();
Editor is loading...