Untitled

 avatar
user_4748127
plain_text
2 years ago
514 B
3
Indexable

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();