Asset transfers
A user might want to transfer their asset from one wallet to another for various reasons, ie. sending the asset as a gift.
📝Guides
Typescript SDK
1. Initialize the SDK
In order to use the SDK, you need to initialize it.
2. Generate signers
Transferring an asset requires a user's signature, so your application will need to generate signers. Then setup GenericIMXProvider
3. Set the transfer params
The transfer request requires:
- ETH and Stark signers (see previous step)
- Token type, and token amount/details to be transferred
- Address of receiving account
Token types that can be transferred and details required:
- ETH -
amount
- ERC20 -
amount
,tokenAddress
- ERC721 -
tokenAddress
,tokenId
Param | Description |
---|---|
amount | The amount of the token required. If token is ETH, the amount is denominated in wei |
tokenAddress | The address of the smart contract from which the token originates |
tokenId | The token ID of a non-fungible token (only for ERC721 token types) |
📚SDK reference
Example request params for the different token types:
ETH
const unsignedTransferRequest = {
type: 'ETH',
amount: '100000000', // Denominated in wei
receiver: "RECEIVER'S ETH ADDRESS",
};
ERC20
const unsignedTransferRequest = {
type: "ERC20",
amount: "100000000",
tokenAddress: '0x...'
receiver: "RECEIVER'S ETH ADDRESS",
}
ERC721
const unsignedTransferRequest = {
type: 'ERC721',
tokenId: '1',
tokenAddress: '0x...',
receiver: "RECEIVER'S ETH ADDRESS",
};
4. Create the transfer
📚SDK reference
Request
const response = await imxProvider.transfer(
unsignedTransferRequest
);
console.log(response);
Example response:
interface CreateTransferResponseV1 {
/**
* [deprecated] Sent signature
* @type {string}
*/
sent_signature: string;
/**
* [deprecated] The status of transfer
* @type {string}
*/
status: string;
/**
* [deprecated] Time of the transfer
* @type {number}
*/
time: number;
/**
* ID of the transfer
* @type {number}
*/
transfer_id: number;
}