0

I have read several documentations and tutorials about solidity.

There is something which is not very clear for me:

Let's take a basic example:

contract MyContract1
{
   function public_function(uint param) public
   {
      ...
   }

   function private_function(uint param) private
   {
      ...
   }
}

We have 2 kind of situations:

  • Let's imagine another smartcontract MyContract2 who knows the deployment address of MyContract1. MyContract2 can call MyContract1's public or externals functions.
  • A Javascript "DAPP" web application (written with truffle framework for example) can also call MyContract1 public/external functions.

What i want to know is if the rules are the same for a javascript dapp and an external smartcontract like MyContract2 ?

Thanks

3
  • 1
    Yes, they are the same. Dec 24, 2020 at 8:35
  • One more thing: A public attribute can only be read by another contract / external DAPP ?
    – Bob5421
    Dec 24, 2020 at 8:43
  • 1
    The compiler auto-generates a public getter function for every public attribute, baring the same name. So the answer to your question is yes (by calling that function, which "feels" like reading the attribute). Dec 24, 2020 at 8:48

1 Answer 1

0

Sure, they both access MyContract1 in the same way.

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.