I have written my first sample contract. It compiled successfully but when I am trying to run this, it is giving me an error as:

Send transaction failed: Invalid address. if you use injected provider, please check it is properly unlocked.

Code is as follows:

pragma solidity ^0.4.22;

contract Myfirstcontract 
    string private name;
    uint private age;

    function setName (string newName)
        name = newName;

    function getName () returns (string)
        return name;

    function setAge (uint newAge)
        age = newAge;

    function getAge () returns (uint)
        return age;


Please suggest.

  • 1
    how are you running your contract? – mirg Apr 18 '18 at 3:00

As it says "unlock the injected provider", it means you have to unlock the personal account that is associated with your network.

Unlock account 0xee3f0cd76f27d8cff90e23e53e82d461b6e5731e

The newer MetaMask versions sometimes have this error if you are in "Privacy Mode" To resolve it

  1. Go to Metamask
  2. Select Settings
  3. Go to Security and Privacy
  4. Turn off Privacy Mode

When Privacy Mode is on, it doesn't allow remix to read your accounts from injected web3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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