I am able to connect or call the send txn method of ethereum using new metamask script. But i m not able to call the method of any of custom contract. Can someone tell me how can i do in javascript?


2 Answers 2


I am not sure what does your new metamask mean, however I can show you how to call an contract method in 2022:

( assuming you are calling a contract 's mint method )

    async function loadWeb3() {
      if (window.ethereum) {
        window.web3 = new Web3(window.ethereum);

    async function loadContract() {
      let abi = [] // your abi here
      let address = "0xa1b2c3d4..."  // your contract address here
      return await new window.web3.eth.Contract(abi, address);
    async function getCurrentAccount() {
      const accounts = await ethereum.request({ method: 'eth_requestAccounts' });
      return accounts[0];

    async function run() {
      await loadWeb3();
      window.contract = await loadContract();
      const account = await getCurrentAccount();
      let result = await window.contract.methods.mint().send({ from: account });

    if (typeof window.ethereum !== 'undefined') {

refer to: http://siwei.me/blog/posts/blockchain-web3-metamask-contract


you can try Web3 please check this out: https://medium.com/metamask/calling-a-smart-contract-with-a-button-d278b1e76705


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.