Hedera Meta/Gasless Transaction - hedera-hashgraph

I am working on gasless/meta transactions.
Is it possible in hedera to sign the transaction using one account and submit/execute and also pay for the transaction by a different account?

By gasless I'm assuming you mean in the context of smart contracts in which case the answer is no for now. The payer for the transaction is the msg.sender as seen by the contract.
However, native services such as the token service support a model where Alice pays for a transaction that involved Bob sending tokens (or hbar) to Carol.
Alice has to sign the transaction to approve the tx fee payment, Bob also has to sign to approve the transfer or tokens/hbar.

Related

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.

handling data loss from third party integrations

Just curious on best practices for handling potential data loss with a third party integration.
For example, lets say that im integrating stripe for payments. If our platform has a credit system (a user needs X number of credits to do an action on the site), how would you reconcile a loss of data between the platform and after a purchase is made? Going into the example: a user is on the site, purchases a pack of credits for $10. Our platform calls stripe payment when the user clicks "purchase," the purchase is successful but all of a sudden a loss of power happens. We receive the $10 in our stripe, but on our platform the purchase was never "complete" because the loss of power happened immediately after the purchase was made, and there was no time for our system to receive the authorization code to store as completed. I'd imagine this could be common, or in another case where the purchase is complete, but there is some issue between receiving the success code from the payment processor and it causes delay. So, how do you handle this loss of data?
I could think of maybe storing a payment intent on our database with payment status "incomplete" and once a payment is made and we get a code back from stripe, then we update our database with "complete" and we have some job that polls this database every hour or something to check for "incomplete" payments.
What is common in this case?

Google Cloud billing information verify?

I have a problem with google cloud's billing verify. I added a debit card, which has received an X amount of eurocents from Google. To verify my billing, I need to type that amount into the 'billing account'. However, when I click 'billing' it says there are no accounts, when I try to create one, it tells me my billing account is awaiting confirmation. Any ideas?
TL;DR You could experience some issues when adding a payment method to your billing account in Google Cloud. The best you can do if you face any issue after reading the documentation is to contact Billing support.
If you receive an error such as Your card does not support automatic recurring payments or General decline of the card, please select a different form of payment.
As I can see from your question, you tried to verify Your Bank Account, as stated in the documentation:
A small test deposit will appear in your bank account within a few days of adding the account as a payment method. After you see the test deposit, you should verify the deposit as described in Find and enter a test deposit.
Instant bank verification
We offer instant bank verification for Google Cloud customers. Unlike the test deposit verification method, which takes several days to complete, instant bank verification allows you to verify your bank account within seconds.
You can use instant bank verification in either of the following situations:
If you haven't entered your bank account information yet
If you've recently entered your bank account information
Verify your payment method (US only)
Note: Currently, this service is available only to customers with a U.S. bank account.
In the resolve errors when attempting to add or update a payment method section, it mentions that
you might receive an error such as:
Your card does not support automatic recurring payments.
or
General decline of the card. No other information was provided by the issuing bank.
You might encounter these errors if you are using a debit card that requires two-factor authentication...
When you enter a debit card as your form of payment, Google checks whether your issuing bank approves subscriptions or recurring payments using that card. If your bank does not approve, this card will not work for automatic recurring payments.
If you receive an error such as Your card does not support automatic recurring payments or General decline of the card, please select a different form of payment. You can also contact Cloud Billing Support for help.
Therefore, some of the issues when adding a payment to your Cloud Billing account could be related to some bank restrictions and could even be related to some domestic and international regulations, as it occurs to customers in India.
As stated in the Payment Methods documentation:
The payment methods available for your self-serve (online) Cloud Billing account depend on your currency and country. In many countries, you can set up a credit card, debit card, or bank account as a primary payment method.
So in the first instance, I suggest you review the List of countries and regions.
If your country or region is not listed here, this might indicate that your country or region's currency is not supported for Google Cloud charges. In these instances, your Cloud Billing account might incur charges in USD.
For countries or regions not listed here, check the payment options tool for information.
Then, you should check the Supported payment methods:
The types of cards Google services lets you add to payment profiles vary by location and by product.
American Express
MasterCard
Visa
Discover (U.S. only)
JCB (Japan and U.S. only)
Visa Electron (Outside the U.S. only)
Elo credit cards (Brazil only; We don't allow you to add Elo debit cards)
Debit cards with the Visa or MasterCard logo
Bank account
If supported in your country, you can add a bank account to pay.google.com to pay your Cloud Billing account.
Verify Your Bank Account
Depending on your country, you might need to verify your bank account to use it as a payment method by direct debit. A small test deposit will appear in your bank account within a few days of adding the account as a payment method. After you see the test deposit, you should verify the deposit as described in Find and enter a test deposit.
Also, there are some unsupported payment methods:
Debit cards that require two-factor authentication
are not accepted for payment.
Prepaid cards and Virtual Credit Cards (VCCs) are not accepted for payment.
Bank accounts that only support disbursements are not accepted for payment.
Payment via wire transfer is not supported for monthly charge or threshold billing
accounts.
You may pay with a bank account by adding it as a payment method, if
supported in your
country.
So, as long as your payment method is supported, you could add it to your Cloud Billing account.
See also:
Fix payment and billing issues
How to fix a payment issue - YouTube video

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

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.

Handling Transaction Between Paypal and Local Datasase

What is the best practice to handle transaction between application and paypal.
Consider:
I'm Alice and I want send money to Bob
In my DB I see that Bob has $200 and I want to send him $150.
Once transaction is sent I want to update the Bob's account such that it would contain $50.
Now according to PayPal API I can send Pay and receive success. However what happens
if I for example send Pay it succeeds but I fail to receive a response due to network problem. So I assume that error happened and try again and technically I'll send $300 to Bob instead of $150?
How can I handle such a transaction - between a local database that keeps an account and the remote PayPal API?
I had this exact concern recently with an ASP.NET MVC project I was completing for a client.
I learned two things:
Communication between Paypal and your database cannot be trusted (well, didn't really learn this, but it was entirely reinforced)
I now understand why so many websites that have Paypal as a transaction type mention there could be a processing period between the time that the transaction was completed and shipping/delivery of the product is completed.
The way you handle the situation is similar to the way a business could handle personal checks:
A personal check looks like currency (and typically is), but many businesses would like some sort of verification from the bank that funds are available before they accept payment - so they use a machine that asks the bank if funds are actually available.
If the machine says the funds are available, the business trusts it and you complete the transaction. However, the machine can give an error message that typically means "the funds are not available or something went wrong" and the business has a decision to make:
We can trust the customer and accept the check, deliver the product, and hope for the best when later depositing the check to the bank.
Or we can tell the customer that it will take time for the check to clear, deposit the check, wait for the funds to actually arrive in our account, and (if successful) deliver the product after the business receives funding.
This sounds inefficient with the way many businesses operate today, but it is something that does come up. In fact, this is why a lot of businesses stray away from accepting personal checks, they are unreliable when compared to other methods of payment.
Now how does this correlate to handling a Paypal payment?
A Paypal payment looks like currency (and it typically is), but many businesses would like some sort of verification from the Paypal that funds are available before they accept payment - so they use Paypal PDT, IPN, or other method for checking that the transaction was handled appropriately.
If Paypal properly responds to one of the verification requests, the business can trust it and complete the transaction. However, your website may throw an error of some sort (i.e. Paypal could reply with an IPN response of NOTVALID, or you could never get a reply from Paypal). The business has a decision to make:
The business can trust the customer and accept that they have made a Paypal payment and everything should be alright (very bad decision in the case of a Paypal transaction)
Or the business can tell the customer at check-out time that there may be a 72 hour processing period for Paypal payments.
This may not sound like the best way to operate your business, but it is the way we have to deal with an imperfect internet.
I would set up the Paypal payment flow similar to this:
UserA wants to send $100 to another UserB using Paypal
UserA enters the value in the 'checkout field' and is sent over to Paypal to verify the transaction.
UserA is sent back to your website from Paypal and your website performs the IPN check with the details that Paypal has POSTed to your site(I chose IPN in this case - as if we were using Express Checkout as opposed to some other payment gateway that Paypal offers).
If the IPN is VALID, process the transaction as expected.
If the IPN is not VALID, mention to the customer that there may be a delay in processing, have your application send you a notification that a possible Paypal transaction issue has occurred (you may want to include a reference id so that you can quickly find which transaction this notification is referencing), and mark the transaction as pending as opposed to complete or something similar.
An admin of the site who handles these notifications will manually investigate the transaction (or force the website to check with Paypal again - see the Paypal API documentation for details on this) and manually mark the transaction as complete or failed.
Notify those involved of the status of the transaction.
It is annoying that we have to have extra steps involved to make sure the money was transferred, but, as mentioned earlier, we are using an imperfect system and we want to be very certain of the success / failure of financial transactions.
An added bonus to this process is that there is likely to be notifications when someone is tampering with the Paypal payment system - leaving you better equipped to deal with evil-doers in the future.
Please refer this link ,Hope PayPal Authorization & Capture method will be suitable for you ,since you don't want lose the response as well as miscalculated amount transfers, PayPal provides correlation id that can be referred for PayPal to confirm your order status,it will be better to pass the order id to PayPal API.
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/howto_admin_authcapture
http://www.scribd.com/doc/6303345/40/CorrelationID-for-Reporting-Problems-to-PayPal
Good Luck!
This is known as 2-phase commit. As long as paypal does not participate in the same transaction, you will run into problems.
I would debit Alice the $150 and reflect the transaction is "Pending Confirmation", then periodically poll PayPal to synchronize your DB, since you have no control of when the network or PayPal may be available, post, reverse or adjust the transaction. Once PayPal processes the transaction, you can change the status in your DB from "Pending" to "Completed". BTW, this how bank accounts and credit cards are processed. You could apply a double-entry accounting method to your DB. (see this Q&A)
From what i see you need to make sure the transaction is complete otherwise nothing should be done .
If you deposit the money into PayPal API and you do not receive an response from PAYPAL API then you need to rollback the transaction in you DB.

Resources