How to decide cost to launch ethereum smart contract on MainNet - blockchain

I have written and launched a smart contract of solidity in ropsten network. And it is working well. Now I want to launch that on main net. I know few things like
1- Cost to launch depends on the opcodes. Well I have written about 50 lines of smart contract and when seeing opcodes its too large. It is tedious to calculate the approximate cost to launch on main net seeing opcodes.
2 - There is a function in web3js named estimateGas. But it used for only transaction not for launching contract.
3 - There is something like gasPrice and maxGasAmmount which can be used by a miner. Also gasPrice varies from 2 gwei to n gwei.
4 - It also depends upon the variables used in constructor.
I have also refered to this website https://ethgasstation.info/index.php and https://www.myetherwallet.com but couldn't get much info. What can be the gas price and max gas price which can be kept for an ideal contract having some basic functionalities like transfer tokens, check balance, maintain owner and transfer owner etc.
I want to make around 10 billion tokens on main net. Is it possible? If yes what can be the approximate cost for that considering March 2018 for that. I don't mind waiting for 5-15 minutes to launch the contract.

estimateGas will tell you exactly how much gas you need, but pretty much any tool you use to deploy will call that for you. (Yes, that's for estimating the gas usage of a transaction, but deploying a contract is a transaction.)
You already launched to Ropsten, so presumably you managed to use a sensible gas amount then. Do whatever you did to deploy that time.
For the gas price, https://ethgasstation.info/ is indeed a good resource. Right now 2 gwei looks good if you're not in a hurry.

Related

How can i update a variable everytime my smart contract receives ETH?

So the last couple of weeks I spent my freetime on working on a dApp and I'm almost finished there's one last thing I have to implement but I really struggle to do so.
So my dApp is basically a game. To get more players I added a token which the players can earn. I want them to stake their tokens to receive some of the profit the game makes. All the ETH the game makes goes into a treasury contract. That's the same contract where people can stake their tokens. I want them to have a "pending ETH reward" which they can withdraw on their cost. Similar to sushiswap with the difference that there isn't a fixed amount of reward per block. So basically I want the smart contract to assign the Ether it receives to the token stakers based on how much they stake. I don't want the Eth to directly get send to the addresses of the stakers because this would be to pricy.
At first I thought this would be easy but than I looked into it, wasted many hours and found out that I have no clue how to do this. How can I let my contract know that it received ETH and that it should do something evertime it receives Eth? Every type of help is highly appreciated!
My current idea is to make a struct array called "Users". Each User stores the adress, pendingETHreward and amount of staked tokens. Each User should be mapped to the addres of the user. The Problem: I dont know how to update the variable pendingETHreward of each user everytime the contract receives ETH.
You will write a smart contract function that does the logic you described
-> This is simply matter of programming and outside the scope of this question - if you are not on the level of Solidity programming yet that you can do this, then I suggest tutorials and online courses
Mark your function as payable in Solidity
Users will call your smart contract function from their MetaMask and then they attach any number of ETH as the payload for the transaction
Smart contract can then hold this ETH and have internal accounting done for who it belongs based on msg.sender address in Solidity code

Can anyone clarify how much cost it takes for a user to use a function of a smart contract on ethereum blockchain?

Is it even valuable for devoloping Dapps?
Does it take more money(way higher) for a using a smart contract than a normal application?
There are alot of factors involved in calculating the cost of a function. e.g. amount of gas used and gas price etc. If you want to calculate the exact cost of your function executation, you can connect Metamask to your SmartContract(Ethereum node). While sending a transaction it will give you all the required information of your transaction including your transaction cost accorfing to the current Ethereum price.
Transaction Fee depends on Ether Price, Gas Used and Gas Price. For example "standard" ERC20 token transfer:
https://etherscan.io/tx/0xbdcfe0e5d548d707a8b092884509a4182c9bfccaddfef1a7c7b9d4f9d4efe326
NOTE: With 5.8 Gwei Gas Price and $210.06 Ether Price this is a very cheap transaction today.
For more info use ethgasstation.info

What are the concepts needed to program a Cryptocurrency Miner (e.g. XMR miner like XMRig XMR-Stak MinerGate, etc)?

How does one program a Cryptocurrency Miner?
Like
XMRig
XMR-Stak
MinerGate
etc.
You would first need to have a understanding of the concept of PoW. Simply put PoW is hashcash - a miner hashes the block they have created, incrementing a random "nonce" (number used once) until the resultant hash fulfills the "difficulty" requirements. The difficulty is a number that is calculated based on the time between the blocks over the last 2 weeks, it changes to keep blocks being made every 10 mins (ish). For a block to be accepted its hash must be under the difficulty value (and the block must be valid of course). Solo mining software works by polling the coins daemon for the block template (this contains all the highest fee transactions in some cases, in others you have to add them yourself) creating a "coinbase" transaction (a transaction which will pay you the reward once you find a valid block, this is appended to the top of the list of transactions) updating the merkle root of the transactions to include the new coinbase transaction and adding a nonce, you then hash this block - check if the hash fulfills the difficulty and if it doesn't then increment the nonce. The miner keeps doing this until:
1) The miner finds a block - in which case it sends the block to the daemon
2) A block is found by someone else, in which case the miner starts again (getting the new block template bla bla bla).
However most miners are pool miners - in this case the miner connects to a pool via the stratum+tcp protocol and requests a "job", a job is just a string the pool wants you to hash - the pool does the jb of creating the block to be hashed then splits up the task of hashing over all the miners connected. For example the pool might tell alice to hash the block with nonce 0 up to nonce 15,000 and bob to hash with nonce from 15,001 to 30,000, and so on. The pool miner then submits the result of the work. Once a miner finds a solution they tell the pool and the pool sends the block to the pools daemon, it tells the other miners to stop and start work on the new block. It then splits the reward to the miners based on how many jobs they completed - though the way in which this is done is out of the scope of this answer).
TLDR;
You need to have a understanding of how PoW works, a understanding of what method you want to mine with (solo or pool), (if pool) you'll need to understand the tcp+stratum protocol and (if solo) you will need to understand the rpc of the coin you want to make a miner for. I would start by reading through basic and simple solominers, and then building one of your own. Then you can consider moving onto pool miners which are considerably more complicated. If you want your miner to work with GPUs (and most miners do) then you will need to understand common GPU interfaces for both NVIDIA (eg CUDA) and AMD.
I hope this helps and the best of luck and wishes regarding your adventure into the cryptoverse!
Leo Cornelius

write tiny amount of data to block chain? and what block chain are available

I need to write my hash to block chain to make my document legit for life time (want to know how to do that)? Want to know how many block chains are out there and which few are the best ones with least expenses?
You can make a commitment in a Bitcoin transaction in at least a few ways.
1 - including your preimage in OP_RETURN data in an zero value output. This can be done by creating your own transaction manually, but you will have to pay the transaction fee. You could also use a service which aggregates many commitments into one final hash, then you share the fee (or don't pay one at all). One example is OpenTimestamps.
2 - Pedersen commitment - use your preimage to generate an EC public key along with a blinding factor. Does not use extra space in your transaction, therefore can be included in a transaction without additional fees.
3 - Pay-to-contract signature - including another preimage the nonce used in your transaction signature. This also does not take extra space in your transaction, therefore can be included in a transaction without additional fees.
Resources
A good resource is waxwing's blog: https://joinmarket.me/blog/blog/finessing-commitments/
Another good readup on this subject can be found here: https://blog.eternitywall.com/2018/04/13/sign-to-contract/
James Chiang's Teach Bitcoin curriculum: https://teachbitcoin.io/presentations/ecdsa.html#/
And wikipedia: Commitment Scheme
Save your data in any cloud server or ipfs and then deploy any sample smart contract
contract MyToken {
constructor(){}
string my_doc;
function set(string memory link) public{
my_doc=link;
}
function get() public view returns (string memory ){
return my_doc;
}
}```
//and you can use polygon you can do all the stuff in les then one dollar
//by way you watch a simple tutorial how deploy smart contract using remix ide

Amount of Test Data needed for load testing of a web service

I am currently working on a project that requires load testing of web services.
One of the services is being called 60,000 times in the production during Busy-Day/Busy-HR.
{PerfTest Env=PROD}
Input Account Number
Output AccountDetails
Do I really need 60,000 unique account numbers(TEST DATA) for this loadrunner script to simulate the production scenario?
If unique data is required, for endurance test I will have to prepare lot of test data for each web service.
If I don't get that much test data, what is the chance of Load Test being affected due to Application Server Cache mechanism??
Can somebody help me?
Thanks
Ram
Are you simulating a day or the highest volume hour in the last year? This can help you to shape the amount of data that you need. Rarely would you start with a 24 hour test. Instead you would be looking at your high water test of an hour with a ramp up and ramp down, so you would need approximately 1.333* your high water hour's worth of data.
So this can drop your 60K to (potentially) 20K(?) I am making an assumption that your worst hour over the last year is somewhere around 1/3 of your traditional day. I have observed this pattern over and over again in different environments over the past two decades. You will want to objectively verify this with log data or query data to support the number in your environment.
Next up, how many of these inquiries are actually unique? You are really going to need a log of the queries across a day (or your high water hour) to determine this. Log processing tools such as Microsoft Logparser or Splunk/Splunk Storm can help you to pull the observed distribution of unique account references within your data, including counts of those which are multiple. Once you know this you can simply use a data file with a fixed block size for each user for unique data and once the data is exhausted the user exits.