Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
423 B
2
Indexable
Never

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