How does a dapp know if it is the owner of a smart contract

Does a dapp know that it is the owner of a smart contract by

  • The fact that it was deployed at the time the dapp was initialized?
  • The contract address is hard coded in the dapp?
  • The private key is stored in the dapp ?
  • Or signature?

Because I want to use a smart contract to send etc-20 tokens to users from the dapp, I don’t want to have to sign every time a user is to receive coins .

There must be some way that the dapp knows it is ok to call an owner function of a smart contract. without signing each time I want to do a transfer ?

These are generally called the “Approval” functions on the smart contract. Similarly to what Dexes do by asking your approval for making a trade on a new token in your wallet.

You can research more through this -

1 Like

that helps. But what about if you want to have a second contract that disperses funds in a certain fashion or rather tokens . I get that the deploy script is the time to approve and mint tokens to the second contract, however the part I am fuzzy on , is if the smart contract is already approved, can it just transfer tokens < I think so , but how does the dapp know it’s the owner of the smart contract making the transfer calls? Some place in the dapp to hold the signature or private key ? or ???

there will be two transactions, one that makes the approve and another one that will call a smart contract function and that smart contract function will be able to make that transfer if it was approved to do it.

We may not be able to explain it on a forum that succinctly as it requires a little digging on how contracts work. A great place to start is learning how uniswap works behind the scenes at the contract level.

Perhaps this can help -

thanks that did help a lot

1 Like