Contract The contract API provide users the entries to interact with the ERC721 contracts, including deploying the contracts, setting the sponsors and so on.
Contract Actions
Deploy Contract
The Deploy contract
API helps users to deploy a ERC721 or a ERC1155 contract.
Auth Parameter Parameter Example Response Response Example Request Sample
Copy {
"chain": "conflux_test",
"name": "NFT-name",
"symbol": "ENFT",
"owner_address": "cfxtest:aatk708nbb7573bkwumsu00h0r1rtkcdz2chwhttzk",
"type": "erc721",
"base_uri": "",
"royalties_bps": 0,
"royalties_address": "",
"tokens_burnable": false,
"tokens_transferable_by_admin": false,
"tokens_transferable_by_user": false,
"transfer_cooldown_time": 0,
"is_sponsor_for_all_user": false
}
Copy {
"id": 20,
"created_at": "2022-08-22T15:49:42.46+08:00",
"updated_at": "2022-08-22T15:49:42.46+08:00",
"deleted_at": null,
"app_id": 4,
"chain_type": 1,
"chain_id": 1,
"address": "",
"owner_address": "cfxtest:aajb342mw5kzad6pjjkdz0wxx0tr54nfwpbu6yaj49",
"type": 1,
"base_uri": "",
"name": "NFT-name",
"symbol": "ENFT",
"royalties_bps": 0,
"royalties_address": "cfxtest:aajb342mw5kzad6pjjkdz0wxx0tr54nfwpbu6yaj49",
"tokens_burnable": false,
"tokens_transferable_by_admin": false,
"tokens_transferable_by_user": false,
"transfer_cooldown_time": 0,
"hash": "",
"tx_id": 64,
"status": 0
}
Copy curl --request POST \
--url https://api.nftrainbow.cn/v1/contracts/ \
--header 'Authorization: Bearer {JWT}' \
--header 'Content-Type: application/json' \
--data-raw ' {
"chain": "conflux_test",
"name": "NFT-name",
"symbol": "ENFT",
"owner_address": "cfxtest:aatk708nbb7573bkwumsu00h0r1rtkcdz2chwhttzk",
"type": "erc721",
"base_uri": "",
"royalties_bps": 0,
"royalties_address": "",
"tokens_burnable": false,
"tokens_transferable_by_admin": false,
"tokens_transferable_by_user": false,
"transfer_cooldown_time": 0
}'
When the API is called successfully, we need to use the id in response to call Query contract detail API to get the contract address. It takes several seconds that the contract address can be obtained from Query contract detail API.
Update contract admin
The Update contract admin
API provides users the entry to update the admin of the specific contract.
Auth Parameter Response Response Example Request Sample
Copy curl --request PUT \
--url https://api.nftrainbow.cn/v1/contracts/{address}/admin \
--header 'Authorization: Bearer {JWT}' \
--header 'Content-Type: application/json'
Good to know: Conflux provides users the sponsor function. Once a contract is sponsored by an account, the accounts in the contract white list can call this contracts for free.
The Set sponsor
API provides users to set a sponser for a specific contract according to the sponsor' address.
Auth Parameter Response Response Example Requst Sample
Copy {
"sponsor_gas_tx_id": 8475,
"sponsor_collateral_tx_id": 8476
}
Copy curl --request POST \
--url https://api.nftrainbow.cn/v1/contracts/{address}/sponsor \
--header 'Authorization: Bearer {JWT}' \
--header 'Content-Type: application/json'
Note: UP to now, Set sponsor
API can only be called by users free in testnet. In mainnet, Users need to recharge their own wallet.
The Add Contract Sponsor Users
API provides users to add the address in the whitelist.
Auth Parameter Response Response Example Requst Sample
Copy curl --request POST \
--url https://api.nftrainbow.cn/v1/contracts/{address}/sponsor/whitelist/ \
--header 'Authorization: Bearer {JWT}' \
--header 'Content-Type: application/json' \
--data-raw `["cfxtest:aam1eawbm9pzp0dnwv96tts5shnbdfv9nuwu7zgzz8"]`
The Remove Contract Sponsor Users
API provides users to remove the address from the whitelist.
Auth Parameter Response Response Example Requst Sample
Copy curl --request DELETE \
--url https://api.nftrainbow.cn/v1/contracts/{address}/sponsor/whitelist/ \
--header 'Authorization: Bearer {JWT}' \
--header 'Content-Type: application/json' \
--data-raw `["cfxtest:aam1eawbm9pzp0dnwv96tts5shnbdfv9nuwu7zgzz8"]`
Query Informations
Obtain Contract List
The Obtain contarct list
API provides users the entry to get the inforamtion of the contracts deployed in a specified app. The parameter page
and size
are optional parameters.
Auth Parameter Response Response Example Request Sample
The Contract Struct
is listed as follow:
Copy {
"count": 1,
"items": [
{
"id": 1,
"created_at": "2022-08-19T10:48:13.049+08:00",
"updated_at": "2022-08-19T10:49:15.853+08:00",
"deleted_at": null,
"app_id": 4,
"chain_type": 1,
"chain_id": 1,
"address": "cfxtest:acdzrjc92rds9tuta8rdkx3mn10yzf0jny1z3s0s8e",
"owner_address": "cfxtest:aajb342mw5kzad6pjjkdz0wxx0tr54nfwpbu6yaj49",
"type": 1,
"base_uri": "",
"name": "ttt",
"symbol": "test",
"royalties_bps": 0,
"royalties_address": "",
"tokens_burnable": false,
"tokens_transferable_by_admin": false,
"tokens_transferable_by_user": false,
"transfer_cooldown_time": 0,
"hash": "0xcbcedb27eb941a9a4fb6008d343055d98d9fe1ccdba65268680f46af6bf3fa0a",
"tx_id": 49,
"status": 1
}
]
}
Copy curl --request GET \
--url https://api.nftrainbow.cn/v1/contracts/ \
--header 'Authorization: Bearer {JWT}' \
--header 'Content-Type: application/json'
Query detail contract
The Query detail contract
API provides users the entry to get the detail contract information of a specific contract according to the contract's id. The parameter chain
is optional, which can be used to choose the test or main network of conflux.
Auth Parameter Response Response Example Request Sample
Copy {
"id": 10,
"created_at": "2022-08-19T10:48:13.049+08:00",
"updated_at": "2022-08-19T10:49:15.853+08:00",
"deleted_at": null,
"app_id": 4,
"chain_type": 1,
"chain_id": 1,
"address": "cfxtest:acdzrjc92rds9tuta8rdkx3mn10yzf0jny1z3s0s8e",
"owner_address": "cfxtest:aajb342mw5kzad6pjjkdz0wxx0tr54nfwpbu6yaj49",
"type": 1,
"base_uri": "",
"name": "ttt",
"symbol": "test",
"royalties_bps": 0,
"royalties_address": "",
"tokens_burnable": false,
"tokens_transferable_by_admin": false,
"tokens_transferable_by_user": false,
"transfer_cooldown_time": 0,
"hash": "0xcbcedb27eb941a9a4fb6008d343055d98d9fe1ccdba65268680f46af6bf3fa0a",
"tx_id": 49,
"status": 1
}
Copy curl --request GET \
--url https://api.nftrainbow.cn/v1/contracts/detail/{id} \
--header 'Authorization: Bearer {JWT}' \
--header 'Content-Type: application/json'
The Query sponsor
API provides users the entry to get the sponsors of a specific contract according to the contract's address. The parameter chain
is optional, which can be used to choose the test or main network of conflux.
Good to know: Conflux Network can be divided into the main network and the test network. The later is used to test the developed functions for developers.
Auth Parameter Response Response Example Request Sample
Copy {
"gas_sponsor": "cfxtest:aasr1hmezez1wepvh8ew8sk9p40khhhj1ymxwmpaf0",
"gas_sponsor_balance": 10000000000000000000,
"collateral_sponsor": "cfxtest:aasr1hmezez1wepvh8ew8sk9p40khhhj1ymxwmpaf0",
"collateral_sponsor_balance": 100000000000000000000,
"is_all_white_listed": true,
"gas_upper_bound": 5000000000000000
}
Copy curl --request GET \
--url https://api.nftrainbow.cn/v1/contracts/{address}/sponsor \
--header 'Authorization: Bearer {JWT}' \
--header 'Content-Type: application/json'
Good to know: For more detailed information, please refer to the following link.
Query contract admin
The Query contract admin
API provides users the entry to get the admin of the specific contract.
Auth Parameter Response Example Request Sample
Copy {
"cfxtest:aasr1hmezez1wepvh8ew8sk9p40khhhj1ymxwmpaf0"
}
Copy curl --request GET \
--url https://api.nftrainbow.cn/v1/contracts/{address}/admin \
--header 'Authorization: Bearer {JWT}' \
--header 'Content-Type: application/json'
Query Contract Whitelist
The Query Contract Whitelist
API provides users to get the whitelist of the specific contract. Only the addresses in the whitelist can call the contract free.
Auth Parameter Response Response Example Requst Sample
Copy Return the slices of the addresses in the whiltelist.
Copy ["cfxtest:acexyjf36ddwcct171wr1k5srd289zp9te70p67zc1"]
Copy curl --request GET \
--url https://api.nftrainbow.cn/v1/contracts/{address}/sponsor/whitelist/ \
--header 'Authorization: Bearer {JWT}' \
--header 'Content-Type: application/json'