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"

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

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.