1
pragma solidity 0.4.24;

contract UniToken{
    string value="Hello";

    function set(string x) public {
        value = x;
    }
    function get() public view returns (string) {
        return value;
    }
}

.

contract.methods.set(newValue)
.send({ from: "My Ether Address"
})

In the above code, i am using my ether address but its responding with error

"Returned error: unknown account"

Aniket
  • 3,545
  • 2
  • 20
  • 42
Raman
  • 13
  • 4

1 Answers1

1

This code does not supply "Account" to send the message from.

You have to options :

Use web3.eth.account[N] (E.g.: eth.accounts[0]) to send transaction.

contract.methods.set(newValue)
.send({ from: web3.eth.account[0]
})

Or, you need to sign the transaction with your private key.

Example : How to properly create a raw transaction and sign it using web3 in browser

Shamit Verma
  • 534
  • 2
  • 5