Untitled
user_4748127
plain_text
3 years ago
514 B
10
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();
Editor is loading...