0

I created a Smart Contract and a Dapp that Mint some NFTs, however I would like to be able to create: interact with my contract, only through my application. Does anyone know if it's possible? I didn't find any reference about it.

1 Answer 1

0

It is not possible to limit the direct interaction with smart contract in any manner. But you can achieve what you want within the smart contract by having an access logic. The simplest access logic is what is called onlyOwner.

contract Access {
  address private _owner;

  constructor() {
    _owner = msg.sender;
  }

  modifier onlyOwner {
    require(msg.sender == _owner, 'only owner');
    _;
  }

  function pub() external {}
  function priv() external onlyOwner {}
}

In the above contract pub function can be called by anyone, but priv function can only be called by the _owner, which is the address of the wallet which deployed this contract.

It is not possible to restrict the access via domain. With above method, you should be ok as long as you don't reveal the private key of the account you are using.

2
  • Great to know, and you mentioned something important: access logic. Thank you for you time, but with your logic, only my address can 'create', but in fact any address that connects through my App should be able. But I will do what you like said, create a logic, maybe some password by ChainLink inside the contract, idk yet, but thanks for the attention. I don't have 15 reputation to upvote your answer, but thank you very much.
    – brunovjk
    Sep 28, 2022 at 13:56
  • I think I got something, check it out: blog.chain.link/2fa-authentication-smart-contracts/…
    – brunovjk
    Sep 28, 2022 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.