How to limit execution of smart contract only to my dapp?

0 votes
I want to limit the execution of my smart contract only to my dapp to avoid spoofing. How to do it?
Jul 17, 2018 in Blockchain by slayer
• 29,050 points
19 views

1 answer to this question.

0 votes

You can use modifiers to do it like this:
pragma solidity ^0.4.0;

contract MyContract {
  address mAdmin;

  modifier adminOnly {
    if (msg.sender == mAdmin) _;
  }

  function MyContract() {
    mAdmin = msg.sender;
  }

  function doSomething() adminOnly {
    ...
  }
}

You can learn more about it here: http://solidity.readthedocs.io/en/develop/common-patterns.html#restricting-access

answered Jul 17, 2018 by digger
• 27,640 points

Related Questions In Blockchain

0 votes
1 answer

How do I send back ethers to the sender of the tokens in a smart contract?

Whenever a smart contract receives ether via ...READ MORE

answered May 30, 2018 in Blockchain by Perry
• 17,020 points
360 views
0 votes
1 answer

How to get the current state of a smart contract?

Hey, you gotta provide the contract code, and ...READ MORE

answered Aug 1, 2018 in Blockchain by Perry
• 17,020 points
48 views
0 votes
1 answer

How to access member functions of smart contract using web3?

I have implemented a similar feature and ...READ MORE

answered Aug 13, 2018 in Blockchain by slayer
• 29,050 points
73 views
0 votes
1 answer
0 votes
1 answer

Invalid Batch or signature in Savtooth

This will solve your problem import org.apache.commons.codec.binary.Hex; Transaction txn ...READ MORE

answered Aug 1, 2018 in Blockchain by digger
• 27,640 points
68 views
+1 vote
1 answer
0 votes
1 answer

How to use real world/live data in my smart contract?

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

answered Jul 12, 2018 in Blockchain by digger
• 27,640 points
58 views
0 votes
1 answer

How to return data on execution of invoke function?

You can do this using a response ...READ MORE

answered Jul 23, 2018 in Blockchain by digger
• 27,640 points
35 views