Transfer NFT

EndPoint

POST api/v3/nft/transfer

Header

​
Field
Description
Example
X-API-KEY
ApiKey
"HlkcGxbqBeaF76j4rvPaOasyfPwnkQ6B6DQ6THZWbvrAGxzEdulXQvOKLrRWZLnN"
X-API-SIG
​ECDSA Signature, pay attention the signature type, sign the ecdsa hash​
"0xccf0a141fce2dc5cbbd4f802c52220e9e2ce260e86704d6258603eb346eefe2d 4a450005c362b223b28402d087f7065ea5eee0314531adf6a580fce64c25dca81c02"

Request

​
Query Param
Description
Example
exchange
exchangeAddress in exchange info​
​
fromAddress
sender address
​
fromAccountId
sender accountId
10110
toAddress
to address
​
toAccountId
payee accountId
10111,can set to 0 if dont have
token
​NftTokenAmountInfo,transfer tokenId and amount
​
maxFee
TokenAmountInfo of offchain fee,
​
storageId
offchainId of storage Id​
1
validUntil
Timestamp for transfer to become invalid, seconds
​
normally current time + 2 months
eddsaSignature
​
memo
(Optional) memo
​
payPayeeUpdateAccount
true
counterFactualInfo
if it's counterFactual wallet, need pass the info

Response

​
Field
Description
Example
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.
Field
Description
Example
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

Field
Description
Example
tokenId
The Loopring's ERC20 token identifier.
0
amount
The amount of the ERC20 token
"100000000000000000"
​
​

counterFactualInfo

counterFactual Wallet Info
Field
Description
Example
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 ecdsa hash

ecdsa hash is typedata hash
const message = {
from: data.fromAddress,
to: data.toAddress,
tokenID: data.token.tokenId,
amount: data.token.amount,
feeTokenID: data.maxFee.tokenId,
maxFee: data.maxFee.amount,
validUntil: data.validUntil,
storageID: data.storageId,
};
const typedData: EIP712TypedData = {
types: {
EIP712Domain: [
{ name: "name", type: "string" },
{ name: "version", type: "string" },
{ name: "chainId", type: "uint256" },
{ name: "verifyingContract", type: "address" },
],
Transfer: [
{ name: "from", type: "address" },
{ name: "to", type: "address" },
{ name: "tokenID", type: "uint16" },
{ name: "amount", type: "uint96" },
{ name: "feeTokenID", type: "uint16" },
{ name: "maxFee", type: "uint96" },
{ name: "validUntil", type: "uint32" },
{ name: "storageID", type: "uint32" },
],
},
primaryType: "Transfer",
domain: {
name: "Loopring Protocol",
version: "3.6.0",
chainId: chainId,
verifyingContract: data.exchange,
},
message: message,
};

Compute eddsa hash

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

Example

Header

X-API-KEY = l4hd4CGLLGuZ9nEultG4sfhQZDjPp9sv0kMy13cyGgkJyIWDodVSM4S4ucb5WFKN
X-API-SIG = 0xbc2e9c4f93141d2ee967abd83fd9833d99dffe26266a491e9172710e3e0162086a3624e20b5c79ca890d9827a14936606f8d5a98f21142cc1b458927483797771c02

Request

POST api/v3/nft/transfer
{
"ecdsaSignature": "0xbc2e9c4f93141d2ee967abd83fd9833d99dffe26266a491e9172710e3e0162086a3624e20b5c79ca890d9827a14936606f8d5a98f21142cc1b458927483797771c02",
"eddsaSignature": "0x2775ed99224c9aaf06deb484767e7fea1c224d95a16f8791ab8d83f9d3e33744299e54e7913f9250043ae53bfffe900a8c492da1f480ae148974aee7852c956626f25e7b59ab0e189b85aae0f914789af7373fae360afd04db1a61f29b14a0e2",
"exchange": "0x2e76EBd1c7c0C8e7c2B875b6d505a260C525d25e",
"fromAccountId": 10010,
"fromAddress": "0x6b1029c9ae8aa5eea9e045e8ba3c93d380d5bdda",
"maxFee": {
"tokenId": 2,
"amount": "97700"
},
"memo": "test",
"storageId": 1,
"toAccountId": 0,
"toAddress": "0xbB6924b24bA5c6ece81f056cF54E5d720846c183",
"token": {
"tokenId": 32789,
"nftData": "0x2d4a0fc05056c1cd0e2a059b28d2072dc16cd5d083f77b48ea7d397d05e3627a",
"amount": "1"
},
"validUntil": 1655874494
}

Response

{
"hash": "0x235c8bc8c0201013ab1a531d2d977d965b0d357ebe47e40c50ba71201c0cb86f",
"status": "processing",
"isIdempotent": false,
"accountId": 10010,
"tokenId": 0,
"storageId": 1
}
​
Copy link
On this page
EndPoint
Header
Request
Response
Model
NftTokenAmountInfo
TokenAmountInfo
counterFactualInfo
Compute ecdsa hash
Compute eddsa hash
Example
Header
Request
Response