Remix: Uncaught Error: invalid address

Hello, please I am trying to deploy smart contract using openZepellin and Remix as IDE for an application I am developing on my local machine but I am getting ‘Uncaught Error: invalid address’ in my console. Please can anyone assist on this. Thanks

1 Like

Hi @technified,

Welcome to the community :wave:

Thanks for posting in the community forum. It is a long weekend due to a public holiday in Melbourne :australia: so it has taken a bit longer to reply.

Could you share the contract that you are using, along with what you were trying to run at the time that you received the error?

You might want to try the following tutorial: Create an ERC20 using Remix, without writing Solidity

Thanks @abcoathup for reaching out. Find the contract below:

function createcontract() {

        var country = document.getElementById("xcountry").value;

        var city = document.getElementById("xcity").value;

        var landaddress = document.getElementById("xaddress").value;

        var latitude = document.getElementById("xlatitude").value;

        var longitude = document.getElementById("xlongitude").value;

        var landregistryContract = web3.eth.contract([

          {

            inputs: [

              { internalType: "string", name: "country", type: "string" },

              { internalType: "string", name: "city", type: "string" },

              { internalType: "string", name: "landaddress", type: "string" },

              { internalType: "string", name: "latitude", type: "string" },

              { internalType: "string", name: "longitude", type: "string" },

            ],

            stateMutability: "nonpayable",

            type: "constructor",

          },

          {

            anonymous: false,

            inputs: [

              {

                indexed: true,

                internalType: "address",

                name: "previousOwner",

                type: "address",

              },

              {

                indexed: true,

                internalType: "address",

                name: "newOwner",

                type: "address",

              },

            ],

            name: "OwnershipTransferred",

            type: "event",

          },

          {

            inputs: [],

            name: "city",

            outputs: [{ internalType: "string", name: "", type: "string" }],

            stateMutability: "view",

            type: "function",

          },

          {

            inputs: [],

            name: "country",

            outputs: [{ internalType: "string", name: "", type: "string" }],

            stateMutability: "view",

            type: "function",

          },

          {

            inputs: [],

            name: "landaddress",

            outputs: [{ internalType: "string", name: "", type: "string" }],

            stateMutability: "view",

            type: "function",

          },

          {

            inputs: [],

            name: "latitude",

            outputs: [{ internalType: "string", name: "", type: "string" }],

            stateMutability: "view",

            type: "function",

          },

          {

            inputs: [],

            name: "longitude",

            outputs: [{ internalType: "string", name: "", type: "string" }],

            stateMutability: "view",

            type: "function",

          },

          {

            inputs: [],

            name: "owner",

            outputs: [{ internalType: "address", name: "", type: "address" }],

            stateMutability: "view",

            type: "function",

          },

          {

            inputs: [],

            name: "previousowner",

            outputs: [{ internalType: "address", name: "", type: "address" }],

            stateMutability: "view",

            type: "function",

          },

          {

            inputs: [],

            name: "renounceOwnership",

            outputs: [],

            stateMutability: "nonpayable",

            type: "function",

          },

          {

            inputs: [

              { internalType: "address", name: "newOwner", type: "address" },

            ],

            name: "transferOwnership",

            outputs: [],

            stateMutability: "nonpayable",

            type: "function",

          },

        ]);

        var landregistry = landregistryContract.new(

          country,

          city,

          landaddress,

          latitude,

          longitude,

          {

            from: web3.eth.accounts[0],

            data:

              "0x608060405...",

            gas: "4700000",

          },

          function (e, contract) {

            console.log(e, contract);

            if (typeof contract.address !== "undefined") {

              document.getElementById("metamask").innerHTML =

                "Contract mined! address: " +

                contract.address +

                " transactionHash: " +

                contract.transactionHash;

            }

          }

        );

      }
1 Like

Thanks. I found that I have to add window.ethereum.enable(); to the top of my code

1 Like

Hi @technified,

I am glad that you were able to resolve.

You may want to check out PaulRBerg/create-eth-app by @PaulRBerg as a base for your dapp.

1 Like