Skip to content

Lock API

Lock API offers locking NFTs from being traded or releasing them to be traded again.

Deploy lock contract

Creates a transaction that deploys the lock contract. A lock contract offers locking NFTs in a wallet from being traded with other accounts or releasing them to be traded again.

Request URL

Live URL https://bc-api.qpyou.cn/core/v1/lock/contract
Sandbox URL https://sandbox-bc-api.qpyou.cn/core/v1/lock/contract
HTTP Method POST
Content-Type application/json

Header parameters

Field Name Description Type Required
x-network the blockchain networks string Y
Authorization Authentication token required to call the API string Y

Request body

Field Name Description Type Required
name the lock contract name string Y
from the wallet address that deploys the lock contract string Y
executer This is the wallet address that can unlock the locked NFT. The default value is the from address. string N
encoded whether the returned transaction is encoded or not true: Receive the encoded raw transaction string (data.rawTx). false: Receive the decoded data.rawTx (JSON). boolean N

Responses

Field Name Description Type
code api request result code, 0: success number
message the result message String
data API response data json
data.rawTx the transaction data string or json
data.hashedTx This is hashed data.rawTx. This value is only returned when the API header x-network is "polygon" and the Request Body from is an multi sig wallet address. string
data.requestId the unique value that can identify each API request string

Request sample

curl -X 'POST' 
  'https://sandbox-bc-api.qpyou.cn/core/v1/lock/contract' 
  -H 'accept: application/json' 
  -H 'x-network: polygon' 
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJp...' 
  -H 'Content-Type: application/json' 
  -d '{
  "encoded": true,
  "name": "lock_test",
  "from": "0xdcd51770d06B54204abd8c30A25b4583D4cABa39"
}'

Response sample

{
  "code": 0,
  "message": "success",
  "data": {
    "rawTx": "02f8738301388181c2846fc23ac0846fc23ad882cdc49494853bdc9c6add50d7842d1a3117fab38545747080b8...",
    "hashedTx": "0x53e8783e4da707daf58c96a8cea278e7b2a8a5f185af0913b518974556c79076...",
    "requestId": "4d4aa1e5-2bfe-4080-b42f-03319810fe29"
  }
}

Lock NFT

Creates a transaction that the NFT owner account (from) sends the NFT (tokenId) to the lock contract. Once the NFT is sent to the lock contract, the ownership of this NFT is now transferred to the lock contract, and the previous owner can’t send this NFT to another account anymore.

Request URL

Live URL https://bc-api.qpyou.cn/core/v1/nft/contract/{contract}/lock
Sandbox URL https://sandbox-bc-api.qpyou.cn/core/v1/nft/contract/{contract}/lock
HTTP Method POST
Content-Type application/json

Path parameters

Field Name Description Type Required
contract the NFT contract address string Y

Header parameters

Field Name Description Type Required
x-network the blockchain networks string Y
Authorization Authentication token required to call the API string Y

Request body

Field Name Description Type Required
from the wallet address of the NFT owner string Y
lockContract the address of the NFT lock contract string Y
tokenId NFT ID String Y
encoded whether the returned transaction is encoded or not true: Receive the encoded raw transaction string (data.rawTx). false: Receive the decoded data.rawTx (JSON). boolean N

Responses

Field Name Description Type
code api request result code, 0: success number
message the result message String
data API response data json
data.rawTx the transaction data string or json
data.hashedTx This is hashed data.rawTx. This value is only returned when the API header x-network is "polygon" and the Request Body from is an multi sig wallet address. string
data.requestId the unique value that can identify each API request string

Request sample

curl -X 'POST' 
  'https://sandbox-bc-api.qpyou.cn/core/v1/nft/contract/0x777358b228a4720ffa088516294b324f8d24639c/lock' 
  -H 'accept: application/json' 
  -H 'x-network: polygon' 
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJp...' 
  -H 'Content-Type: application/json' 
  -d '{
  "from": "0xA10078576Ca6f63dc6f78ff9a8ed8bd05B51f463",
  "lockContract": "0xD6e69da7f1be111394dfef4C48eaC9b52ddf2Fd0",
  "tokenId": "1",
  "encoded": true
}'

Response sample

// When the encoded is set to true 
{
  "code": 0,
  "message": "success",
  "data": {
    "rawTx": "02f8d3830138810b8458e948068458e948168302e71494ebd9144485089ebe248f8490...",
    "hashedTx": "0x53e8783e4da707daf58c96a8cea278e7b2a8a5f185af0913b518974556c79076...",
    "requestId": "5743f0aa-0323-47fc-a3da-173eee27bbe4"
  }
}
// When the encoded is set to false
{
  "code": 0,
  "message": "success",
  "data": {
    "rawTx": {
      "from": "0xdcd51770d06B54204abd8c30A25b4583D4cABa39",
      "to": "0xebd9144485089ebe248f8490984a60579407c262",
      "data": "0xb88d4fde000000000000000000000000dcd51770d06b54204abd8c30a25b4583d4cab...",
      "nonce": 11,
      "chainId": 80001,
      "gas": 190228,
      "maxFeePerGas": 1491259270,
      "maxPriorityFeePerGas": 1491259255
    },
    "hashedTx": "0x53e8783e4da707daf58c96a8cea278e7b2a8a5f185af0913b518974556c79076...",
    "requestId": "dd33ddd8-31fa-4491-9c3c-2f912f7059bc"
  }
}

Unlock NFT

Creates a transaction that the lock contract sends back the NFT (tokenId) to the NFT owner account. Once an NFT is sent back to the NFT owner account, this account can resume trading this NFT.

Request URL

Live URL https://bc-api.qpyou.cn/core/v1/lock/contract/{contract}/unlock
Sandbox URL https://sandbox-bc-api.qpyou.cn/core/v1/lock/contract/{contract}/unlock
HTTP Method POST
Content-Type application/json

Path parameters

Field Name Description Type Required
contract the address of the NFT lock contract string Y

Header parameters

Field Name Description Type Required
x-network the blockchain networks string Y
Authorization Authentication token required to call the API string Y

Request body

Field Name Description Type Required
nftContract the NFT contract address string Y
from the wallet address of the account (the owner of the lock contract) that deployed the lock contract string Y
tokenId NFT ID String Y
encoded whether the returned transaction is encoded or not true: Receive the encoded raw transaction string (data.rawTx). false: Receive the decoded data.rawTx (JSON). boolean N

Responses

Field Name Description Type
code api request result code, 0: success number
message the result message String
data API response data json
data.rawTx the transaction data string or json
data.hashedTx This is hashed data.rawTx. This value is only returned when the API header x-network is "polygon" and the Request Body from is an multi sig wallet address. string
data.requestId the unique value that can identify each API request string

Request sample

curl -X 'POST' 
  'https://sandbox-bc-api.qpyou.cn/core/v1/lock/contract/0xa245824a24daf3b312d3f59c7debf162c4993e8b/unlock' 
  -H 'accept: application/json' 
  -H 'x-network: polygon' 
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJp...' 
  -H 'Content-Type: application/json' 
  -d '{
  "nftContract": "0xdcd51770d06B54204abd8c30A25b4583D4cABa39",
  "from": "0xdcd51770d06B54204abd8c30A25b4583D4cABa39",
  "tokenId": "1",
  "encoded": true
}'

Response sample

{
  "code": 0,
  "message": "success",
  "data": {
    "rawTx": "02f873830138810c8451f4d5c08451f4d5cf83018c0694572f47db51a98...",
    "hashedTx": "0x53e8783e4da707daf58c96a8cea278e7b2a8a5f185af0913b518974556c79076...",
    "requestId": "0e40db96-8964-410f-81e2-a968269872d4"
  }
}

Get owner information of locked NFT

Returns the information of the account that owns a locked NFT (tokenId).

Request URL

Live URL https://bc-api.qpyou.cn/core/v1/lock/contract/{contract}/token/{tokenId}/account
Sandbox URL https://sandbox-bc-api.qpyou.cn/core/v1/lock/contract/{contract}/token/{tokenId}/account
HTTP Method GET
Content-Type application/json

Path parameters

Field Name Description Type Required
contract the address of the NFT lock contract string Y
tokenId NFT ID String Y

Header parameters

Field Name Description Type Required
x-network the blockchain networks string Y
Authorization Authentication token required to call the API string Y

Query parameters

Field Name Description Type Required
nftContract the NFT contract address string Y

Responses

Field Name Description Type
code api request result code, 0: success number
message the result message String
data API response data json
data.owner the address of the NFT owner string

Request sample

curl -X 'GET' 
  'https://sandbox-bc-api.qpyou.cn/core/v1/lock/contract/0xa245824a24daf3b312d3f59c7debf162c4993e8b/token/1/account?nftContract=0x777358b228a4720ffa088516294b324f8d24639c' 
  -H 'accept: application/json' 
  -H 'x-network: polygon' 
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJp...'

Response sample

{
  "code": 0,
  "message": "success",
  "data": {
    "owner": "0xA10078576Ca6f63dc6f78ff9a8ed8bd05B51f463"
  }
}

Get locked NFT information

Get the information of an owner’s (owner) locked NFT located at a lock contract (contract).

Request URL

Live URL https://bc-api.qpyou.cn/core/v1/lock/contract/{contract}/account/{owner}/tokens
Sandbox URL https://sandbox-bc-api.qpyou.cn/core/v1/lock/contract/{contract}/account/{owner}/tokens
HTTP Method GET
Content-Type application/json

Path parameters

Field Name Description Type Required
contract the address of the NFT lock contract string Y
owner the address of the NFT owner string Y

Header parameters

Field Name Description Type Required
x-network the blockchain networks string Y
Authorization Authentication token required to call the API string Y

Responses

Field Name Description Type
code api request result code, 0: success number
message the result message String
data API response data json
data.tokens the locked NFTs list array
data.tokens.owner the wallet address of the NFT owner string
data.tokens.nftAddress the NFT contract address string
data.tokens.tokenId NFT ID string

Request sample

curl -X 'GET' 
  'https://sandbox-bc-api.qpyou.cn/core/v1/lock/contract/0xa245824a24daf3b312d3f59c7debf162c4993e8b/account/0x9428e6eF51FEb2201676deEc11B7E36F7c1F0765/tokens' 
  -H 'accept: application/json' 
  -H 'x-network: polygon' 
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJp...'

Response sample

{
  "code": 0,
  "message": "success",
  "data": {
    "tokens": [
      {
        "owner": "0xA10078576Ca6f63dc6f78ff9a8ed8bd05B51f463",
        "nftAddress": "0xeBd9144485089EbE248f8490984A60579407c262",
        "tokenId": "2"
      }
    ]
  }
}