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,080 points
32 views

1 answer to this question.

+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
• 17,020 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,050 points
311 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
57 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
141 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
• 26,550 points
3,115 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
• 17,020 points
84 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
• 17,020 points

edited Aug 10, 2018 by Omkar 465 views