Peer-to-Peer Payments
Transfer funds from one user to another without Payment Hubs.
Before we continue, please ensure that you have had a look at our Supported Ethereum Chains, followed the steps in Install Etherspot SDK and how to Bootstrap Etherspot SDK. We're assuming that you have completed these steps before going forward.
In this example, we're going to show you how to transfer the funds using Peer-to-Peer Deposits
We're going to be using two Etherspot SDK instances here:
A
ropsten
Etherspot SDK for our sender user wallet
A
ropsten
Etherspot SDK for our receiver user wallet
Getting started
For this guide, we're going to transfer ETH from one wallet to another wallet on the Ropsten
network. To achieve this, we're going to send ETH from our p2pPaymentDeposit
address linked to the user wallet to the another wallet on the Ropsten
network.
We're going to assume that we're working with the following definitions:
Ensure Payment Deposit Address is funded
For this process to work, we need to make sure that the Payment Deposit have enough liquidity in them to facilitate the transfer to another wallet. We're going to be working with the p2pDepositAddress
from our user wallet Etherspot SDKs. We can get this address as follows:
The p2pDepositAddress
exists purely to provide liquidity for other operations. Your address
is unaffected.
We now need to add Test ETH from the Ropsten Faucet. Please follow the instructions on the Ropsten Faucet website to receive Test ETH to the p2pDepositAddress
.
Once you have received the Test ETH to the p2pDepositAddress
in the senderEtherspotUser
instance, we're ready to move on.
Transfer Funds via Payment Deposit
We need to transfer the desired amount of funds from our p2pDepositAddress
in the senderEtherspotUser
instance to the p2pDepositAddress
in the receiverEtherspotUser
instance
For this, we need to use the Etherspot SDK function updateP2PPaymentChannel
to transfer from one Etherspot SDK to another with the following code:
Withdraw Funds from Payment Channel
To be able to withdraw the above amountToSend
from the receiver Etherspot SDK, we need to perform a few final steps.
We're now working primarily with the Ropsten
Receiver Etherspot SDK.
From the above output
we need to get the hash to commit from the receiver SDK. This will allow us to withdraw the amount transferred. This can be done with the following:
Make sure that the receiver wallet has enough gas fees to pay on your p2pPaymentDepositAddress.
Last updated