My Contract is:

pragma solidity ^0.4.8;

contract Awards {
  address public owner;
  string  public name1;
  string  public name2;
  string  public name3;

  function Awards() {  
    owner = msg.sender;
    name1 = "Avinash";
    name2 = "Balaji";
    name3 = "Mohit";

  modifier OnlyOwner() {
    if(owner ==  msg.sender) {
    else {

  function setAward1(string s) OnlyOwner {
    name1 = s;

  function setAward2(string s) OnlyOwner {
    name2 = s;

  function setAward3(string s) OnlyOwner {
    name3 = s;


I deployed my contract on Local private node.

I run my geth node by using following command:

geth --datadir "filepath" --rpc --rpcaddr "localhost" --rpccorsdomain "*" --networkid 1234 --mine --minerthreads 1 console

In Javasacript , I connected my application front-end with local node using web3:

web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

I successfully connected my front-end. I could even access public state variables name1, name2 and name3. But when I called setAward1(), setAward2() or any other function, I got this error:

Error: unknown account at Object.InvalidResponse.

I called function like

myContract = web3.eth.contract(AbiArray).at(contractAddress);

myContract.displayAward(username, function(err,res) {
  console.log("In display Award");
  if(!err) {
    console.log("winner is" + res);

Please help me!!! Thank you in advance.

  • 1
    displayAward function is not in contract. Can you share the exact way you are trying hit the setAward1() function?
    – Aniket
    Apr 28, 2017 at 7:43
  • Did you find a solution to this? I'm struggling to fix this issue myself. Jul 28, 2017 at 18:31

1 Answer 1


The displayAward() method have to appear in the smart contract. Then if you are using web3 1.0.0, it should be used this way:

myContract.methods.displayAward(username).send({from: account_address})
.on('transactionHash', function(hash){

.on('receipt', function(receipt){

.on('confirmation', function(confirmationNumber, receipt){

.on('error', console.error);


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.