Skip to main content

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.

Core SDK

1. Initialize the Core SDK

In order to use the Core 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.

3. Set the transfer params

The transfer request requires:

  1. ETH and Stark signers (see previous step)
  2. Token type, and token amount/details to be transferred
  3. Address of receiving account

Token types that can be transferred and details required:

  • ETH - amount
  • ERC20 - amount, tokenAddress
  • ERC721 - tokenAddress, tokenId
ParamDescription
amountThe amount of the token required. If token is ETH, the amount is denominated in wei
tokenAddressThe address of the smart contract from which the token originates
tokenIdThe 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
const walletConnection = { ethSigner, starkSigner };

// Transfers the asset
const response = await client.transfer(
walletConnection,
unsignedTransferRequest
);

// Print out the response
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;
}