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,040 points
13 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.
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,620 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
• 16,450 points
181 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
• 16,450 points
35 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,040 points
43 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,620 points
38 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,620 points
43 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,620 points
24 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.