How Can a Owner Add a Function to Already Deployed Smart Contract - solidity

I'll be frank, I made a stupid mistake. In polygon network I deployed a NFT smart contract. I forgot to add withdraw function in my smart contract. Can we add this function to my smart contract that already deployed.
You can see the smart contract code in here:
https://polygonscan.com/address/0xeCd093eD38449d8d64bb015D97072BdcaA594832#code

Unfortunately, you cannot.
Upgrading smart contracts is not possible on EVM chains unless the contracts were designed for it. You can read more on the topic on Ethereum StackExchange.
I also suggest you test you minimally unit tests contracts before deploying.

Related

Is there a way to test a solidity smart contract funtions

a bit of a noob question. I'm looking to test a solidity smart contract function without waiting 6 days. It's a feature implemented that will allow me to interact with the contract and be paid X amount only after 6 days. How can test that? TIA
well it really depends on your tool set, if you are using hardhat you can write a test, that way you can easily know if that function work as intended, here to see hardhat testing and here to simulate the pass of the time you only need to know how many blocks are mined in that time to use it

Generating a random number from smart contract using Hedera Hashgraph

How to securely generate a random number on a smart contract using solidity from Hedera? I've been searching for an answer for a while now and looks like most of them recommend the use of Chainlink VRF?
I'm still new to this but on my limited understanding, nodes on Ethereum can somehow tamper the smart contract states or results. Since Hedera has a governing council nodes that we could somehow trust, maybe a simple generated random number from Solidity can be trusted? Or I'm getting this all wrong since I'm still learning.
Random numbers from smart contract has many use case, if someone from Hedera devs could see this thread please provide an easy solution.
To generate a verifiable random number in a solidity smart contract on Hedera, you'd do the same as you would on Ethereum or any other EVM compatible network. You could use an existing library, like vrf-solidity.
Once you have the solidity file you'd like to use you'd then compile the smart contract, add the file to Hedera, and deploy the smart contract. The steps to do so can be found in the deploy your first smart contract tutorial found on Hedera docs.
Note this HIP which introduces a native transaction type for generating random numbers and which will be available as a precompile for use in smart contracts.
https://hips.hedera.com/hip/hip-351

Good solidity smart contract tutorials, videos, examples

I am looking for a good resource for solidity advanced smart contracts development free resource or books.
Scenarios like
- Crowdsale
- Insurance sector
- Banking
I have done some research on Open Zepplin which is a good resource for smart contracts but there is not a good explanation.
Any resource related help from the community will be appreciated.
I've made 2 videos but the demand on such content is still not really high so I stopped recording new ones.
Part 1
Part 2
And I also have a repository which contains working contracts of token and kind of advanced crowdsale which is using Oracles, whitelist, bonuses, referall program, etc. It is pretty easy to start to play with because we've put everything into docker containers

Is Contract testing necessary when both consumer and provider are developed by the same company in different scrum teams?

Is Contract testing necessary when both consumer and provider are developed by the same company in different scrum teams ?
Yes, definitely. Contract testing is particularly useful when you rely on an 'external' service, where by external I mean any service that is not under your direct control, including the case you mentioned. Here is an interesting article from Martin Fowler.
Short answer: no, contract testing isn't necessary in any situation, the same as unit testing.
Long answer: Not having testing greatly reduces your confidence as a developer to deploy without breaking anything. Unit testing is good for testing an individual function, while contract testing is good at figuring if your changes will affect any consumers of the data you provide. The consumers of your data could be anyone, it could be someone across the room from you, a client external of the company or even yourself. The whole point is to try to segment and simplify the development process so that problems are caught earlier on. It also has the added benefit that you don't need to run the data producer locally just to have the consumer working while developing, which is definitely a great bonus when the consumer doesn't (or can't) have access provider code, like an external client.
These tools are meant to make your life as a developer simpler and easier to manage, Pact strives to accomplish this in your workflow and to prevent issues from happening in production and giving the developer a quicker feedback loop of potential issues.
The team that wrote Pact in the first place was responsible for both ends of the integration, and they still found contract testing valuable. Just because you're developing both sides now, doesn't mean that you will continue to be responsible for both sides in the future. Contract tests will ensure that changes made by future developers will not break anything.

How should I use namespaces in WCF contracts?

After reading this, this and this I think I somewhat get what they mean with versioning data contracts. Is it so that the recommended approach is to have my data and message contracts implement an interface and set the DataContract(Name = "SameValue") for different namespaces?? I would then create a new class with the same name and a different contract? If that is correct it's almost too easy to be true. The reason I am asking is that I want to smoke test the client against the production service and fail startup if the contracts are newer than the service.
Does anyone have any further recommendations / readings?
Yes, that attribute allows for versioning of your contract.
Decent article for best practices on handling change in WCF.