Transfer
Last updated
Last updated
This page instructs you how to transfer assets from a logged-in users Passport wallet to another wallet.
The user must be logged into your application via Passport
Once you have a user logged into your application via Passport, you will be able to initiate the transfer of an asset (ETH
, ERC20
or ERC721
) from the users Passport wallet to another wallet. To do this, we must create an UnsignedTransferRequest
argument that will be passed to the transfer
function. The structure of the UnsignedTransferRequest
varies depending on the type
property, which specifies the type of asset that is being transferred. You'll need to ensure that the wallet that you're attempting to transfer the asset from is in fact the owner, otherwise the transfer request will fail.
1.1. Transferring an ERC721
To transfer an ERC721
, the following properties must be specified:
type: The type of asset to transfer. Must be ERC721
tokenId: The unique identifier of the NFT to be transferred
tokenAddress: The address of the ERC721
contract to be transferred
receiver: The address of the wallet that will receive the ERC721
For example:
To transfer ERC20
, the following properties must be specified:
type: The type of asset to transfer. Must be ERC20
amount: The amount of the ERC20
token to be transferred
receiver: The address of the wallet that will receive the ERC20
tokenAddress: The address of the ERC20
contract to be transferred
For example:
To transfer ETH
, the following properties must be specified:
type: The type of asset to transfer. Must be ETH
amount: The amount of the ERC20
token to be transferred
receiver: The address of the wallet that will receive the ETH
For example:
Once you've created an UnsignedTransferRequest
, it's time to perform the transfer. This can be done by calling the transfer
function on the IMXProvider
instance that is returned from the connectImx
function:
The transfer
function returns a promise that resolves to a CreateTransferResponseV1
, which contains the following properties:
sent_signature: The signature of the transfer that was executed
status: The status of the transfer
time: The time that the transfer occurred
transfer_id: The unique identifier for the transfer
In the event of a failure, the promise will reject with the following properties:
code: The error code associated with the failure
details: A string containing details about the failure
message: A string containing a message that describes the failure
1.2. Transferring an ERC20
1.3. Transferring ETH