How can nodes interact with a Smart Contract?

+1 vote

When deploying a smart contract how can I let nodes on my own platform (mobile or web) interact with it? 

Like in the following contract:

contract Test {
    event Log(address addr);

    function logMe () public {
        Log(msg.sender);
    }
}
Do I need to have access to the private and public keys of the nodes in order to use it? Or Is it possible to allow those nodes to interact with the blockchain through their own accounts without the need to have their credentials? 
Apr 27, 2018 in Blockchain by Johnathon
• 9,070 points
20 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
+1 vote
Best answer

If you are using Remix IDE to deploy your smart contract on blockchain and you have created API for your contract, you are actually interacting with your contract with web. You can find your API and contract addresses by clicking on details in compile tab.

Then you can use web3 and inject it into your web browser ( install Metamask then you have web3 injected to the browser already )

Then create a contract API like instance by setting web3 provider and ABI and contract address you got from the above steps.

And at last, call your contract functions.

Here is the way you can interact with your deployed contract:

var fooContract = web3.eth.contract( YOUR_ABI, (err, ctr) => { return ctr} );
     web3.eth.defaultAccount = web3.eth.accounts[0];
     $scope.accounts = web3.eth.accounts;

     console.log(web3.eth.defaultAccount);
    var CONTRACT = fooContract.at('YOUR_Deployed_contract_ADDRESS',(err, ctr)=>{
      return ctr;
    } ) 
Now You can easily use the CONTRACT variable to call its public functions.
CONTRACT.contractFunction(params)
answered Apr 27, 2018 by Perry
• 16,450 points

selected Aug 10, 2018 by Omkar

Related Questions In Blockchain

0 votes
2 answers

How do I interact with a smart contract on a private network through web3.js

I found a blog that explains how ...READ MORE

answered Aug 20, 2018 in Blockchain by slayer
• 29,040 points
154 views
0 votes
1 answer
+1 vote
2 answers

Can I include real world data in a smart contract? If so, how?

You cant access/embed real world data using ...READ MORE

answered Jul 17, 2018 in Blockchain by sapan
37 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
79 views
+1 vote
3 answers

Removing double quotes from a string from JSON response in PHP

Just remove the json_encode call, and it should work: $resp ...READ MORE

answered Sep 12, 2018 in Blockchain by digger
• 27,620 points
1,736 views
0 votes
1 answer
0 votes
1 answer

Can I swap an ERC-20 token with a Neo NEP5 token using a smart contract?

Every Blockchain has a separate administration. So, it ...READ MORE

answered Jun 4, 2018 in Blockchain by Perry
• 16,450 points
67 views
0 votes
1 answer

How can I deploy a HelloWorld contract on my testrpc network?

The problem lies in the command: truffle migrate Your truffle migrate command ...READ MORE

answered Apr 27, 2018 in Blockchain by Perry
• 16,450 points

edited Aug 10, 2018 by Omkar 374 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.