Mint NFT

mint nft in Loopring layer2, only can mint ERC1155 in layer2 now

EndPoint

POST api/v3/nft/mint
FieldDescriptionExample

X-API-KEY

ApiKey

"HlkcGxbqBeaF76j4rvPaOasyfPwnkQ6B6DQ6THZWbvrAGxzEdulXQvOKLrRWZLnN"

Request

Query ParamDescriptionExample

exchange

exchangeAddress in exchange info

minterAddress

minter address

"0x2aa52B5fc52c9BD3Bc7555AAB1f565f06baafF5D"

minterId

minter accountID

10110

toAddress

(Optional) to address

toAccountId

to accountId

10111,can set to 0 if dont have

nftType

0 for ERC1155, 1 for ERC721, now only support ERC1155

0

tokenAddress

tokenAddress, computed by

"0x2aa52B5fc52c9BD3Bc7555AAB1f565f06baafF5D"

nftId

nftId, TODO: add link

"0x3b65907396d1259f85e649531a43380aab7cfab61475f129783da7d6a6c257f1"

amount

how many tokens to be mint.

"1"

royaltyPercentage

fee to the creator of each NFT transaction. 1 ~ 10, percentage

1, means 1%

maxFee

TokenAmountInfo, minter fee, request type is 9

storageId

the offchain id of fee token

1

validUntil

Timestamp for transfer to become invalid, seconds

normally current time + 2 months

eddsaSignature

royaltyAddress

(Optional) fee to the address, default is minter address

"0x2aa52B5fc52c9BD3Bc7555AAB1f565f06baafF5D"

counterFactualInfo

if it's counterFactual wallet, need pass the info

Response

FieldDescriptionExample

hash

The hash identifier set by the user at the time of submission, can use this hash to get the transfer info

"0x1d923ca783 4dc90484fa2e b611f0f0bc7e 741bb107007e bea19ba8caea b4f9d3"

status

Whether the order was successfully submitted or not, please note, user may query after a while to get real process status, as most offchain requests are async processed Allowable : ['received', 'processing', 'processed', 'failed']

"received"

isIdempotent

Idempotent of submit transfer response, submit same transfer again idempotent will be true

"false"

Model

NftTokenAmountInfo

Wrapper object used to describe a token associated with a certain quantity.

FieldDescriptionExample

tokenId

The Loopring's NFT token identifier.

32769

amount

The amount of the NFT

token

"2"

nftData

The Loopring's NFT token data identifier which is a hash string of NFT token address and NFT_ID

"0xf7c932351186c3a9053f313eefa16209c018f7f1dba8aa 8ca7100400f7c31085"

TokenAmountInfo

ERC20 token amount info, used for fee here

FieldDescriptionExample

tokenId

The Loopring's ERC20 token identifier.

0

amount

The amount of the ERC20 token

"10000000000000000"

counterFactualInfo

counterFactual Wallet Info

FieldDescriptionExample

walletFactory

Counter factual wallet factory contract address

"0xbbbbca6a90 1c926f240b89 eacb641d8aec 7aeafd"

walletOwner

Counter factual wallet owner address, NOT the wallet address

"0xbbbbca6a90 1c926f240b89 eacb641d8aec 7aeafd"

walletSalt

Salt to generate address from owner & other related info

"1"

Compute eddsa hash

export function getNftData(request: NFTMintRequestV3) {
  const hasher = Poseidon.createHash(7, 6, 52);
  const nftIdHi = new BN(request.nftId.substr(2, 32), 16).toString(10);
  const nftIdLo = new BN(request.nftId.substr(2 + 32, 32), 16).toString(10);
  const inputs = [
    request.minterAddress,
    request.nftType,
    request.tokenAddress,
    nftIdLo,
    nftIdHi,
    request.royaltyPercentage,
  ];
  return hasher(inputs).toString(10);
}

const inputs = [
    new BN(ethUtil.toBuffer(request.exchange)).toString(),
    request.minterId,
    request.toAccountId,
    getNftData(request),
    request.amount,
    request.maxFee.tokenId,
    request.maxFee.amount,
    request.validUntil,
    request.storageId,
  ];
  const hasher = Poseidon.createHash(inputs.length + 1, 6, 53);
  const hash = hasher(inputs).toString(10);

Last updated