Create an order

POST /nft/orders/:chainId/

Examples

The process of composing an NFT order and the payload to POST to API endpoint is pretty much the same as with usual "fungible to fungible token" orders.

The only differences are:

  • slightly different endpoint route (/nft/orders/... instead of /ft/orders/... )

  • makerAssetType and takerAssetType fields are required

  • makerAsset and takerAsset contain not plain token addresses, but token address and token type encoded as described in Body parameters

  • takerAssetId and makerAssetId will contain NFT tokenId . If it's "NFT to fungible" order, takerAssetId = 0 and makerAssetId = tokenID. If it's "fungible to NFT", then the opposite.

curl -X POST \
  'https://api.paraswap.io/nft/orders/137' \
  --header 'Content-Type: application/json' \
  --data-raw '{
	"nonceAndMeta": "6696393496368457207383969069655254624825140823245405670718046208",
	"expiry": 1664716033,
	"makerAsset": "4094980474276800865989028098863468306593436022900",
	"makerAssetId": "1027",
	"takerAsset": "990092240248101882666250324982272499898038834061",
	"takerAssetId": "0",
	"maker": "0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf",
	"taker": "0x0000000000000000000000000000000000000000",
	"makerAmount": "1",
	"takerAmount": "50",
	"signature": "0x762dd1eb9447d10a24adff2c16dd2a6a4f6abdeff2e51fc1df0428129e4b7c1a00100a35f936e591956a5c86d3d502ecb591134bc8c0f32f12fd7533c199975e1c"
}'

Query parameters:

  • chainId:network id (Ethereum Mainnet = 1)

Body parameters

{
	"nonceAndMeta": "6696393496368457207383969069655254624825140823245405670718046208",
	"expiry": 1664716033,
	"makerAsset": "4094980474276800865989028098863468306593436022900",
	"makerAssetId": "1027",
	"takerAsset": "990092240248101882666250324982272499898038834061",
	"takerAssetId": "0",
	"maker": "0x05182E579FDfCf69E4390c3411D8FeA1fb6467cf",
	"taker": "0x0000000000000000000000000000000000000000",
	"makerAmount": "1",
	"takerAmount": "50",
	"signature": "0x762dd1eb9447d10a24adff2c16dd2a6a4f6abdeff2e51fc1df0428129e4b7c1a00100a35f936e591956a5c86d3d502ecb591134bc8c0f32f12fd7533c199975e1c"
}
  • nonceAndMeta: needs to be encoded as described in:

Data structure in our centralized system
  • makerAsset and takerAsset needs to be encode as packed field containing address of an ERC20/721/1155 token that maker want to sell to the taker (between 0-19 bits). Token type encoded as show above on 20-21 bits.

Example encoding in JavaScript:

const ERC20 = 0;
const ERC721 = 2;
const ERC1155 = 1;

const encodeAddress = (address, assetType) => BigInt(address) | (BigInt(assetType) << BigInt(160));
encodedAddress = encodeAddress('0xcd494673999194365033d7a287af9f0a3b163874', ERC721);

Response

Understand the response by checking our dedicated page:

Data structure in our centralized system
{
	"order": {
		"expiry": 1664716033,
		"createdAt": 1663852073,
		"transactionHash": null,
		"chainId": 137,
		"nonceAndMeta": "6696393496368457207383969069655254624825140823245405670718046208",
		"maker": "0x05182e579fdfcf69e4390c3411d8fea1fb6467cf",
		"taker": "0x0000000000000000000000000000000000000000",
		"takerFromMeta": "0x0000000000000000000000000000000000000000",
		"makerAsset": "0xcd494673999194365033d7a287af9f0a3b163874",
		"makerAssetId": "1027",
		"makerAssetType": 2,
		"takerAsset": "0xad6d458402f60fd3bd25163575031acdce07538d",
		"takerAssetId": "0",
		"takerAssetType": 0,
		"makerAmount": "1",
		"fillableBalance": "1",
		"takerAmount": "50",
		"signature": "0x762dd1eb9447d10a24adff2c16dd2a6a4f6abdeff2e51fc1df0428129e4b7c1a00100a35f936e591956a5c86d3d502ecb591134bc8c0f32f12fd7533c199975e1c",
		"orderHash": "0xe40182a75563c4c84e2ff4f2b4b44045fc94f66c929780ee82560d30cbadeb83",
		"permitMakerAsset": null,
		"type": "LIMIT",
		"state": "PENDING"
	}
}

Last updated