Transfer ERC20
Send ERC20 tokens to another account on Loopring L2
The SDK provides the ability to transfer a supported ERC20 token to another account on Loopring Layer2.
Trade value should with decimals
sdk.toBig(value).times("1e" + TOKEN_INFO.tokenMap.LRC.decimals)
const { exchangeInfo } = await LoopringAPI.exchangeAPI.getExchangeInfo();
const LOOPRING_EXPORTED_ACCOUNT.exchangeAddress = exchangeInfo;
1
const { apiKey } = await LoopringAPI.userAPI.getUserApiKey(
2
{
3
accountId: accInfo.accountId,
4
},
5
eddsaKey.sk
6
);
7
console.log("apiKey:", apiKey);
8
const { userBalances } = await LoopringAPI.userAPI.getUserBalances(
9
{ accountId: LOOPRING_EXPORTED_ACCOUNT.accountId, tokens: "" },
10
apiKey
11
);
1
const transferResult = await LoopringAPI.userAPI.submitInternalTransfer({
2
request: {
3
exchange: LOOPRING_EXPORTED_ACCOUNT.exchangeAddress,
4
payerAddr: accInfo.owner,
5
payerId: accInfo.accountId,
6
payeeAddr: LOOPRING_EXPORTED_ACCOUNT.address2,
7
payeeId: LOOPRING_EXPORTED_ACCOUNT.accountId2,
8
storageId: storageId.offchainId,
9
token: {
10
tokenId: TOKEN_INFO.tokenMap.LRC.tokenId,
11
volume: LOOPRING_EXPORTED_ACCOUNT.tradeLRCValue.toString(),
12
},
13
maxFee: {
14
tokenId: TOKEN_INFO.tokenMap["LRC"].tokenId,
15
volume: fee.fees["LRC"].fee ?? "9400000000000000000",
16
},
17
validUntil: LOOPRING_EXPORTED_ACCOUNT.validUntil,
18
},
19
web3,
20
chainId: sdk.ChainId.GOERLI,
21
walletType: sdk.ConnectorNames.Trezor,
22
eddsaKey: eddsaKey.sk,
23
apiKey: apiKey,
24
});
25
console.log("transferResult:", transferResult);
Last modified 6mo ago