How can i work with single Wallet having multiple addresses using web3Js? - cryptocurrency

I am new to cryptocurrency application development. I am using web3js library and reference is
https://web3js.readthedocs.io/en/1.0/web3-eth-accounts.html for managing wallet balance and multiple account address link with single wallet. How can i do this?
We want every user deposit ether comes to out(application) wallet so we can reduce transaction charges as for individual it will many times(between our app, ethernet, user address, so on) from one account to other.

Many exchanges implement an overlay SQL Database to manage account balances, as banks do.
The accounting API on bitcoin (or its' inheritance crypts) does not support that very well and it might get you confusing, which is why the accounting API has been deprecated.
You would need to:
Allow users to register accounts at your database.
Create an address using the RPC API, and associate it to the user logged in.
Monitor the user balance by logging every transaction associated to his wallets.

Related

Hedera Minting DAPP, How to connect wallet

Im coming from the 'other' blockchains and not sure how we would authenticate a Hedera user on a DAPP. Essentially I need to create a minting DAPP.
I need the user to connect his wallet, pay using HBAR and get his token.
Do I need to use a wallet provider like hashpack or something?
Today there are limited, mostly custodial design options available. This is subject to change with HIP-179 External Transaction Signing for SDK and other clients.
Prior to HIP-179, most applications are either:
Using a single managed custodial account on their web server.
Tying a traditional login(email, password) or session to an application-specific generated Hedera account.
Asking users for keys as a login.
Involving some counterparty risk wherein a transaction is sent from a 3rd party wallet (e.g. sending hbar) and a promise to send a token, etc. back.
There are obvious security and scam concerns with most of these models. Once HIP-179 is in place it will be easier for extensions like HashPack and others to sign transactions.

Metamask: sending multiple transactions, without prompting user each time

Say, I have an interactive dapp, like a game and I want the user's actions to be saved on the blockchain (maybe these are moves in the game of chess, whatever).
So, from my understanding, options are:
Create dynamic wallet via web3, prefill it from the metamask and send as many transactions as I want.
Somehow negotiate with the user to trust the dapp and let metamask send transactions on user's behalf without pesky prompting.
What is the right option (if any)? Turns out, metamask has a whole permission escalation framework, yet I wasnt able to ask the right permission.
You can access user funds in several ways:
ask users to deposit in a smart contract and keep track of balances there
ask users to allow your smart contract to spend their tokens via ERC20 allowance
How often will user actions be saved on the blockchain?
Even if your dapp has access to all user funds via a shared wallet or ERC20 allow() + transferFrom() you'll still need somebody to trigger a transaction and pay gas fees whenever you're updating chain state.

SQL - Methods of storing intermediate sign-up information for users

I am designing a Node + MySQL backend for a service that requires two-factor authentication to be set up for all users as a part of the sign-up process. Users first submit a primary phone number and password (with the phone number being used for sign-in), upon which the server sends them an SMS with a six-digit code. Only after they enter the code is their account fully created.
This poses the problem of how to store data for users in the intermediate state after entering username/password but before verifying the code. Such "pending users" will not be shown in searches, do not need to store all the data a regular user would, and will be deleted after a few days if never verified. Furthermore, since every user must enable TFA to fully sign up, there will be orders of magnitude more users than "pending users". Thus, it does not seem sensible to me to have all users simply store an "isVerified" flag. I am familiar with SQL on a technical level but have no experience designing databases for production, and I am wondering what alternate mechanisms I should consider to solve the aforementioned.
My current idea is to have a separate table of pending users, having only those columns necessary to store intermediate signup information. When a user verifies, a row is created in the real user table, the signup information is copied over, and the corresponding is row deleted from the pending users table. However, this makes it somewhat ugly to ensure that the primary phone numbers are unique across both tables (which is an additional requirement of the service).
What methods/techniques should I consider to improve my solution?
You can store this data same way as store session information on server.

In app purchases Auto renewable

your server must track purchases and allow user to restore purchased subscriptions to all iOS devices owned by a single user
I also need to track purchases and allow user to restore purchased subscriptions to all iOS devices owned by a single user. However, I am not aware of any mechanism that will allow me to identify all iOS devices owned by a single user from the app. I am not even aware of any mechanism for identifying the AppleID used by the user from the app. So how am I supposed to do this?
If you are using auto-renewable subscription you can just use the restore feature of store kit. If you're using non-renewable you must allow users to share their subscription across their devices. There are several ways to accomplish this. If you own a server, you can generate a key with a purchase. Associate a number with this key that indicates how many times a user has restored to another device (say, 5). When a user then enters this key on another device, you decrease this number. You would thus have to add a "Share" button in your app that would give the user this key. And you would need an "Unlock" button where the user can enter this code. If you are interested I could also find a method for you that doesn't require a server (but this is less secure).
Hope this helps.
EDIT:
sorry, just noticed you're talking about auto renewable:
http://developer.apple.com/library/ios/#documentation/StoreKit/Reference/SKPaymentQueue_Class/Reference/Reference.html
restoreCompletedTransactions is what you're after

How to make payment to store business account byu paypal?

I am developing an mobile app where I present products (items) from different stores just like ebay.com. User can select product, can add to cart and then finally can make payment via paypal.
I have created an Paypal business account on sandbox. Currently all payment made by users are coming to this business account I mentioned in my code. But my requirement is different. I want that payment should go to store's (product owner's) account.
So I made changes so that whenever i make call to paypal I chnaged business account email to store owner email address and payment done successfully. :) Payment posted to store owner business.
I made changes only in paypal.recipient email address but still paypal object is created by my paypal application ID. This is what I am worried about. Does it will work on production mode? I really doubt that.
Please help me guys!!!
What API or service are you using to do this? Are you just using Website Payments Standard, Exprses Checkout, or one of the other API? You mentiioned application id, are you using Adaptive Payments? You could use Adative Payments to do what you are wanting to, if you are not already doing this. This would allow you to process payments and split it between different accounts. In your business model, it would allow you to split the payments between different store owners if the buyers checkout contained items from different merchants/stores.

Resources