Deploy NFT

Construct a transfer to Layer 2 broker and trigger deployment of tokenAddress in Layer 1

chevron-rightStep 1: Get Accounthashtag

Prepare Loopring Layer 2 account. Retrieve account information.

const {accInfo} = await LoopringAPI.exchangeAPI.getAccount({
  owner: LOOPRING_EXPORTED_ACCOUNT.address,
});
console.log("accInfo:", accInfo);
chevron-rightStep 2: Get eddsaKeyhashtag

Generate EdDSA key.

const eddsaKey = await signatureKeyPairMock(accInfo);
console.log("eddsaKey:", eddsaKey.sk);
chevron-rightStep 3: Get apiKeyhashtag

Retrieve the account's API key.

const {apiKey} = await LoopringAPI.userAPI.getUserApiKey(
  {
    accountId: accInfo.accountId,
  },
  eddsaKey.sk
);
console.log("apiKey:", apiKey);
chevron-rightStep 4: Get feehashtag

Get deploy tokenAddress fee and set the transfer token amount.

const fee = await LoopringAPI.userAPI.getNFTOffchainFeeAmt(
  {
    accountId: accInfo.accountId,
    requestType: sdk.OffchainNFTFeeReqType.NFT_DEPLOY,
    amount: "0",
  },
  apiKey
);
console.log(fee);
chevron-rightStep 5: Get storageIdhashtag

Get transfer token tokenId's storageId. Using "LRC" as an example:

 const storageId = await LoopringAPI.userAPI.getNextStorageId(
  {
    accountId: accInfo.accountId,
    sellTokenId: TOKEN_INFO.tokenMap["LRC"].tokenId, // same as Step 7. transfer->token->tokenId
  },
  apiKey
);
chevron-rightStep 6: Get brokerhashtag

Get Loopring Layer 2 broker and set to payeeAddr of transfer

const {broker} = await LoopringAPI.exchangeAPI.getAvailableBroker();
chevron-rightStep 7: Build Transfer and deployhashtag
circle-check

Last updated