// Connect to Metamask
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
const contractAddress = '0x123456789abcdef123456789abcdef123456789a'; // Replace with your contract address
const contractABI = [...]; // Replace with your contract ABI
const contract = new ethers.Contract(contractAddress, contractABI, signer);
async function getValue() {
const result = await contract.getValue();
console.log('Value:', result);
}
getValue();
async function setValue(newValue) {
const transaction = await contract.setValue(newValue);
await transaction.wait(); // Wait for the transaction to be mined
console.log('Transaction Hash:', transaction.hash);
}
setValue('new value');