Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: jammy99 on March 19, 2018, 11:06:06 AM



Title: working with balance management in a game
Post by: jammy99 on March 19, 2018, 11:06:06 AM
I'm working in a online game project, Where users will deposit ETH into their account for playing game.

My problem is, Once a user deposit some ETH into his wallet. Example 0.10 ETH

So how we can track this balance and update user balance into our database, And allow user to play game. So while playing game user's balance will deduct or increase from our database balance not from directly their ETH wallet built into our website.

So how is it possible to track users deposit only once, So same deposit amount can not be grabbed by our code?

How peoples do this kind of stuff?


Title: Re: working with balance management in a game
Post by: bob123 on March 19, 2018, 01:06:39 PM
I'm working in a online game project, Where users will deposit ETH into their account for playing game.

You seem to ask a lot questions regarding deposits/withdrawals for your website.
Please be concerned that if you are not a very skilled programmer (which you obviously aren't) and you don't hire one to code it for you,
someone will find a vulnerability and either 1) crash your system or 2) withdraw everything. Just a matter of time.



So how is it possible to track users deposit only once, So same deposit amount can not be grabbed by our code?

Well, you credit the deposit after X confirmation. What do you exactly mean by 'grabbed by our code' ?
You have to build the whole backend with security in mind. There isn't just one call to make it secured and working flawlessly



How peoples do this kind of stuff?

They learn how to code or hire someone who knows how to.


Title: Re: working with balance management in a game
Post by: jammy99 on March 20, 2018, 09:08:42 AM
looks like you dont want to help, what you have written i already know all that about me.

Looks like you have no idea how does gaming websites works with crypto currencies and you don't know balance management as well and how to generate child addresses under a parent address.

You totally misunderstood the question. Or may be your are willing to get hired. BTW please if you don't have answer of anyone's question do not just make any reply or comment.


Hiring peoples is not a big deal, but i just came here to learn how things go on.

BTW i will wait for someone to answer my questions


Title: Re: working with balance management in a game
Post by: TheQuin on March 20, 2018, 10:46:00 AM
So while playing game user's balance will deduct or increase from our database balance not from directly their ETH wallet built into our website.

Normally they would not have a wallet. Once a deposit is made it is in the site's wallet and credited to their account in the database.


Title: Re: working with balance management in a game
Post by: Xynerise on March 20, 2018, 01:32:27 PM
You can do it in different ways:

    1 Create a new smart contract for every user, which requires gas to create. Could be expensive if you have a lot of users.

    2 Create an external account (normal ETH address) for each user.
    You'll need gas to consolidate the funds to your cold wallet (if any)

    3. Use a single smart contract for all customers.

    Either way, you still need to employ someone to do it for you since you have no idea how any of this works.

    Good luck.


Title: Re: working with balance management in a game
Post by: BitifyStartup on March 20, 2018, 03:02:57 PM
1)You should write a php script that can check the wallets balance from a database you have written, and run a cronjob every 5 minutes.
2)Your database should include the users ID and the Address used for depositing funds.
3)Your code should read this value and display it to your user.
4)Your game should deduct the "gamecost" from the user balance and update it.



// get user balance

            if (empty($user_balances[$user_id])) {
               $bal_info = User::getBalance($user_id,$wallet['eth']);
               $user_balances[$user_id] = $bal_info['balance'];
            }

I am available for hire you can visit www.bitify.co.za for more information. My entire platform works with user balances, and assuming by your question you should not be dealing with other users funds if you don't know the basics about crypto-currencies / programming.