0

I am new to smart contracts, and I am developing a smart contract for a game. I am trying to understand if the smart contract that I created is efficient or not.

I have deployed the smart contract on the testnet. Then, I made some transactions and I saw that the CPU usage change, it is not the same even if I call the same action.

There is a way to know how much CPU an action will consume(approximately)?

If an action of a smart contract use around 1ms of CPU in the test net, in the mainnet the usage of CPU will be similar?

Thank you.

1 Answer 1

0

So far there is no easy way to reliably measure CPU-usage of actions as there are many factors playing into this but testnet-cpu-usage is most of the time a good benchmark anyways.

I'd recommend you to use multiple testnets to measure cpu-usage while calculating avg-cpu-usage.

Mandel v3.1.0-rc1 now also contains a "Transaction Resource Cost Estimation"-endpoint and it's very likely upcoming versions will contain this endpoint while Node-Operators on both testnets (few nodes on testnets are already running Madnel V3.1.0-rc1) and mainnets will host it (take a look here)

Often the diverse mainnets are a bit faster in processing than the testnets but it's not certain that they are while multiple other factors play into this. (take a look here)

When your smart contract gets closer to a production state you can also just test on a mainnet.

Your Answer

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

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