Untitled

 avatar
unknown
plain_text
2 years ago
423 B
3
Indexable

const contractInstance = new web3.eth.Contract(abi, contractAddress);

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

 
  const totalEthInContract = await web3.eth.getBalance(contractAddress);

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

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

getPrice();